Following the directions from the main clang static analyzer web page (http://clang-analyzer.llvm.org/scan-build.html)...
I have a small C file that is heinously bug-ridden (badcode.c):
int main(int argc, char ** argv)
{
int j;
int a[4];
puts(a[j]);
return 'a';
}
In order to get a basic idea how the clang static analyzer (scan-build) words, I run:
scan-build -v clang badcode.c
It outputs:
scan-build: Emitting reports for this run to '/tmp/scan-build-2012-08-17-1'.
scan-build: 'clang' executable not found in '/usr/share/clang/scan-build/bin'.
scan-build: Using 'clang' from path: /usr/bin/clang
badcode.c:7:2: warning: implicit declaration of function 'puts' is invalid in C99 [-Wimplicit-function-declaration]
puts(a[j]);
^
1 warning generated.
scan-build: Removing directory '/tmp/scan-build-2012-08-17-1' because it contains no reports.
Ok, great, clang gives a little warning, but a.out is still produced. And how come it doesn't produce a report? The unititialized variable j should be a painfully obvious red flag to any static analyzer -- why isn't it reported?
Am I simply using the wrong command line arguments?