<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: Clang analyzer marks variable which is returned as part of a struct as "Value stored to variable is never read""
href="http://llvm.org/bugs/show_bug.cgi?id=22769">22769</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>False Positive: Clang analyzer marks variable which is returned as part of a struct as "Value stored to variable is never read"
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>3.4
</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>simon.brandner@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>In the function from the dlmalloc source code:
size_t dlmalloc_set_footprint_limit(size_t bytes) {
size_t result; /* invert sense of 0 */
if (bytes == 0)
result = granularity_align(1); /* Use minimal size */
//Clang complains: Value stored to 'result' is never read
if (bytes == MAX_SIZE_T)
result = 0; /* disable */
else
result = granularity_align(bytes);
gm->footprint_limit = result;
//it is returned here:
return gm->footprint_limit;
//the original code returns directly without previous assignment, like:
//return gm->footprint_limit = result;
}
scan-build complains about "Value stored to 'result' is never read".
As it is returned as part of a struct, I wonder why it needs to be read before.
Does clang expect some sanity check for it?
You can find the entire source at:
<a href="https://android.googlesource.com/platform/bionic/+/master/libc/upstream-dlmalloc/malloc.c">https://android.googlesource.com/platform/bionic/+/master/libc/upstream-dlmalloc/malloc.c</a></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>