Following the tutorial here : http://clang-analyzer.llvm.org/scan-build.html and I write a toy example to check whether scan-build can help find the dead code.
The following is the testing code:
#include <stdio.h>
int main () {
printf("haha this is testing code\n");
return 0;
int c = 10;
}
and I run the following in the command-line:
scan-build -v gcc -c test.c
however the scan-build gives the following output:
It does not discover that int c = 10; will not be reached.
Do I miss something?

The
alpha.deadcode.UnreachableCodechecker finds the bug:Command line:
Output:
See http://clang-analyzer.llvm.org/alpha_checks.html for more alpha (experimental) checkers.