[cfe-dev] Static analyzer gives no warnings in #included *.c files

Robert Purves listrp at gmail.com
Mon Jan 23 14:06:18 PST 2012


Ping.
Is this by design or a bug?


> $ cat foo.c
> int foo( void ) { 
>    int x;
>    if ( x ) return 1; /* uninitialized */
>    return 0;
> }
> 
> $ cat main.c
> #include "foo.c" /* ignored by static analyzer? */
> int main( void ) { 
>    return 0;
> }
> 
> $ clang main.c --analyze
> $ clang --version
> clang version 3.1 (trunk 148340)
> 
> 
> Analysis of main.c is defective. Explicit analysis of foo.c does give a warning.
> 
> $ clang foo.c --analyze
> foo.c:3:10: warning: Branch condition evaluates to a garbage value
>    if ( x ) return 1; /* uninitialized */
>         ^
> 1 warning generated.

Robert P.





More information about the cfe-dev mailing list