[LLVMbugs] [Bug 15585] New: Divide by zero check confused by loop
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Mon Mar 25 04:43:21 PDT 2013
http://llvm.org/bugs/show_bug.cgi?id=15585
Bug ID: 15585
Summary: Divide by zero check confused by loop
Product: clang
Version: 3.2
Hardware: Macintosh
OS: MacOS X
Status: NEW
Severity: normal
Priority: P
Component: Static Analyzer
Assignee: kremenek at apple.com
Reporter: aneumann at mpi-inf.mpg.de
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
Hello,
I've been trying out the static analyzer. Apparently the divide by zero check
is easily confused. Consider the following piece of code:
#include <iostream>
using namespace std;
void f1() {
for(int x=10; x>0; x--);
int j = 0;
int i = 5/j;
cout << i << endl;
}
void f2() {
int j = 0;
int i = 5/j;
cout << i << endl;
}
int main() {
f1();
f2();
return 0;
}
The analyzer does not see the divide by zero in f1(), only in f2(). Since I see
no reason why a loop in the function should prevent the detection of this
divide by zero, I submit this bug report.
I also copypaste the verbose output
infmb1800:skip list aneumann$ scan-build-mp-3.2 -v -v -v clang++-mp-3.2
sa_test.cpp
scan-build: Using '/opt/local/libexec/llvm-3.2/bin/clang' for static analysis
scan-build: Emitting reports for this run to
'/var/folders/f3/s_kr99qx01g03x4f4q73clvr0000gp/T/scan-build-2013-03-25-10'.
clang++-mp-3.2 sa_test.cpp
[LOCATION]: /Volumes/NO NAME/code/skip list
#SHELL (cd '/Volumes/NO NAME/code/skip list' &&
'/opt/local/libexec/llvm-3.2/bin/clang++' '-cc1' '-triple'
'x86_64-apple-macosx10.7.0' '-analyze' '-disable-free' '-main-file-name'
'sa_test.cpp' '-analyzer-store=region' '-analyzer-opt-analyze-nested-blocks'
'-analyzer-eagerly-assume' '-analyzer-checker=core' '-analyzer-checker=unix'
'-analyzer-checker=osx' '-analyzer-checker=deadcode'
'-analyzer-checker=security.insecureAPI.UncheckedReturn'
'-analyzer-checker=security.insecureAPI.getpw'
'-analyzer-checker=security.insecureAPI.gets'
'-analyzer-checker=security.insecureAPI.mktemp'
'-analyzer-checker=security.insecureAPI.mkstemp'
'-analyzer-checker=security.insecureAPI.vfork' '-analyzer-output' 'plist' '-w'
'-mrelocation-model' 'pic' '-pic-level' '2' '-mdisable-fp-elim' '-masm-verbose'
'-munwind-tables' '-target-cpu' 'core2' '-target-linker-version' '134.9'
'-resource-dir' '/opt/local/libexec/llvm-3.2/bin/../lib/clang/3.2'
'-fmodule-cache-path'
'/var/folders/f3/s_kr99qx01g03x4f4q73clvr0000gp/T/clang-module-cache'
'-fdeprecated-macro' '-fdebug-compilation-dir' '/Volumes/NO NAME/code/skip
list' '-ferror-limit' '19' '-fmessage-length' '0' '-stack-protector' '1'
'-mstackrealign' '-fblocks' '-fobjc-runtime=macosx-10.7.0'
'-fobjc-dispatch-method=mixed' '-fobjc-default-synthesize-properties'
'-fencode-extended-block-signature' '-fcxx-exceptions' '-fexceptions'
'-fdiagnostics-show-option' '-analyzer-display-progress'
'-analyzer-output=html' '-o'
'/var/folders/f3/s_kr99qx01g03x4f4q73clvr0000gp/T/scan-build-2013-03-25-10'
'-x' 'c++' 'sa_test.cpp')
ANALYZE (Syntax): sa_test.cpp f1
ANALYZE (Syntax): sa_test.cpp f2
ANALYZE (Syntax): sa_test.cpp main
ANALYZE (Path): sa_test.cpp main
sa_test.cpp:13:11: warning: Division by zero
int i = 5/j;
~^~
1 warning generated.
scan-build: 1 bugs found.
scan-build: Run 'scan-view
/var/folders/f3/s_kr99qx01g03x4f4q73clvr0000gp/T/scan-build-2013-03-25-10' to
examine bug reports.
--
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/20130325/befc1d0f/attachment.html>
More information about the llvm-bugs
mailing list