Hi All,
Given the following code:
// test.cpp
int foo(int len) {
int j = 0;
if (len < 10)
j = 42 / j;
return j;
}
the command
clang --analyze test.cpp
issues the bug report
tu.cpp:6:10: warning: Division by zero
j = 42 / j;
However, it seems that merely introducing another function which calls foo() with an argument that would not trigger a division by zero nullifies the bug report. For instance, analyzing
// test.cpp
int foo(int len) {
int j = 0;
if (len < 10)
j = 42 / j;
return j;
}
void bar() {
int m = 12;
foo(m);
}
in the same way will NOT issue a bug report. Isn't this a bug in the static analyzer?
Note: I tested this with clang 3.7.0 and 3.8.0.
~Scott Constable