<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 --- - Unable to find div-by-zero after a for loop"
href="https://llvm.org/bugs/show_bug.cgi?id=26984">26984</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Unable to find div-by-zero after a for loop
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>3.7
</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>tones111@hotmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>analyzing the following source file is unable to find the divide by zero bug
for some number of loop iterations. It can find it when the loop iterates 4
times, but not with >= 5 iterations...
int main()
{
for (int a = 0; a < 4; ++a);
int b = 0;
b = 4 / b;
return 0;
}
scan-build clang++ -Wall -Werror main.cpp
scan-build: Using '/usr/bin/clang-3.7' for static analysis
main.cpp:5:4: warning: Value stored to 'b' is never read
b = 4 / b;
^ ~~~~~
1 warning generated.
scan-build: 1 bug found.
If I modify the loop to end at a < 3 I see the expected output...
scan-build clang++ -Wall -Werror main.cpp
scan-build: Using '/usr/bin/clang-3.7' for static analysis
main.cpp:5:4: warning: Value stored to 'b' is never read
b = 4 / b;
^ ~~~~~
main.cpp:5:10: warning: Division by zero
b = 4 / b;
~~^~~
2 warnings generated.
scan-build: 2 bugs found.</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>