<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW " title="NEW --- - raw_ostream calls memcpy() with NULL destination in unbuffered mode" href="https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_bugs_show-5Fbug.cgi-3Fid-3D23650&d=AwMBaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=MdW7yJcqHGtsgV72WZKPyvJX_Rpc-YnndSL32yWkzow&s=4WBTu0r1CVlgWe6k7BC-MeZj4mJeEdnKwP1Y733wBQM&e=">23650</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>raw_ostream calls memcpy() with NULL destination in unbuffered mode
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.6
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Support Libraries
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>andrey.vihrov@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Using LLVM 3.6 and compiling with GCC 5.1 with UndefinedBehaviorSanitizer
enabled, this program:

#include <llvm/Support/raw_ostream.h>

int main()
{
    llvm::errs().SetUnbuffered();
    llvm::errs() << "";
}

produces

/usr/include/llvm/Support/raw_ostream.h:171:40: runtime error: null pointer
passed as argument 1, which is declared to never be null

The problematic place is here:
<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_include_llvm_Support_raw-5Fostream.h-3Fview-3Dmarkup-23l168&d=AwMBaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=MdW7yJcqHGtsgV72WZKPyvJX_Rpc-YnndSL32yWkzow&s=o1Nts8bzuFNKLpBAMe63miEpYxX0achrVxms9HZIjoI&e=">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/raw_ostream.h?view=markup#l168</a>
 In unbuffered mode, OutBufCur is a null pointer, but when Size == 0, the code
still tries to call memcpy() with it.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>