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: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    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.
_______________________________________________
llvm-bugs mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to