[llvm-bugs] [Bug 26984] New: Unable to find div-by-zero after a for loop
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Mar 17 20:42:51 PDT 2016
https://llvm.org/bugs/show_bug.cgi?id=26984
Bug ID: 26984
Summary: Unable to find div-by-zero after a for loop
Product: clang
Version: 3.7
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: Static Analyzer
Assignee: kremenek at apple.com
Reporter: tones111 at hotmail.com
CC: llvm-bugs at lists.llvm.org
Classification: Unclassified
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.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160318/1bf4312e/attachment.html>
More information about the llvm-bugs
mailing list