<html>
<head>
<base href="https://bugs.llvm.org/">
</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 - alpha.deadcode.UnreachableCode false positive when asserting on a float"
href="https://bugs.llvm.org/show_bug.cgi?id=39802">39802</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>alpha.deadcode.UnreachableCode false positive when asserting on a float
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>7.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Static Analyzer
</td>
</tr>
<tr>
<th>Assignee</th>
<td>dcoughlin@apple.com
</td>
</tr>
<tr>
<th>Reporter</th>
<td>riku.dev@riksteri.eu
</td>
</tr>
<tr>
<th>CC</th>
<td>dcoughlin@apple.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=21164" name="attach_21164" title="unreachable-repro.cpp">attachment 21164</a> <a href="attachment.cgi?id=21164&action=edit" title="unreachable-repro.cpp">[details]</a></span>
unreachable-repro.cpp
The attached sample code produces an analyzer warning about unreachable code
inside the nested for-loops (sample also inlined below). The warning is clearly
a false positive, since I can see the output of the "unreachable" code when I
execute the original, non-minimal application that reproduces this warning.
Command:
clang --analyze -Xanalyzer -analyzer-checker=alpha.deadcode.UnreachableCode
unreachable-repro.cpp
Output:
unreachable-repro.cpp:11:4: warning: This statement is never executed
continue;
^~~~~~~~
The warning still occurs if the "continue" is replaced with actually useful
code. The "continue" was the simplest statement I could come up with here.
If the assert is removed or split into two like this:
assert(0.f <= input);
assert(input <= 1.f);
then the warning does not appear.
If one or both of the two loops are removed, the warning does not appear.
If the function argument is an integer instead of a floating point type, the
warning does not appear.
I am using the pre-built 64-bit Windows binaries. This occurs at least in
release build version 7.0.0 and snapshot builds 6.0.0-r320423 and
8.0.0-r346630.
============================================
#include <assert.h>
void unreachable_repro(float input)
{
assert(0.f <= input && input <= 1.f);
for(int i = 0; i < 1; ++i)
{
for(int k = 0; k < 1; ++k)
{
continue;
}
}
}</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>