<html>
<head>
<base href="http://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 --- - False positive scoping issues, deref pointer, dead init, uninit arg, val, etc."
href="http://llvm.org/bugs/show_bug.cgi?id=21335">21335</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>False positive scoping issues, deref pointer, dead init, uninit arg, val, etc.
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</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>Static Analyzer
</td>
</tr>
<tr>
<th>Assignee</th>
<td>kremenek@apple.com
</td>
</tr>
<tr>
<th>Reporter</th>
<td>stevemac321@live.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>Could be related to active bugs, e.g. 11722?
The main case, simple (suspected)related repro follows:
Scan-build flagged the following in std::<locale>
libcxx/include/locale:3240:21: warning: Dereference of null pointer
*__nc++ = '-';
~~~~~~~~^~~~~
Code looks like this:
if (__wn - __wb.get() > __bz-2)
{
__h.reset((char*)malloc(static_cast<size_t>(__wn - __wb.get() +
2)));
if (__h.get() == 0)
__throw_bad_alloc();
__nc = __h.get();
}
if (__neg)
*__nc++ = '-';
I changed the code and rebuilt the lib like this and still got the warning
//after __h.reset...
__nc = __h.get();
if(__nc == nullptr)
throw..
Here is a stand-alone repro. I do not get the deref issue, but it does seem to
get thrown off by the if blocks
#include <exception>
#include <cstdlib>
#include <iostream>
int main() {
std::unique_ptr<char, void(*)(void*)> sp(0, std::free);
char buf[100];
char * p = buf;
if(true) {
sp.reset((char*)malloc(static_cast<size_t>(99)));
p = sp.get();
if(p == nullptr)
throw std::bad_alloc();
}
if(true)
*p++ = '-';
std::cout << *p;
}</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>