[cfe-dev] Several missing warnings

रजनीश rdogra at earthlink.net
Sat Jul 18 23:51:02 PDT 2009


> gcc gives 5 warnings but clang gives none.
>
> $ cat test.c
> int main( void )
> {
>     unsigned x, y;
>     if ( x == -1 ) x = x/0;
>     x = x++;
>     return 0;
> }
> $ clang test.c -O1 -Wsign-compare -Wuninitialized -Wunused -Wsequence-
> point
> $ clang --version
> clang version 1.0 (http://llvm.org/svn/llvm-project/cfe/trunk 76360)
> Target: i386-apple-darwin9
> Thread model: posix
> $ gcc test.c -O1 -Wsign-compare -Wuninitialized -Wunused -Wsequence-
> point
> test.c: In function 'main':
> test.c:4: warning: comparison between signed and unsigned
> test.c:4: warning: division by zero
> test.c:5: warning: operation on 'x' may be undefined
> test.c:3: warning: unused variable 'y'
> test.c:4: warning: 'x' is used uninitialized in this function
>
> Bugzilla filed:
> <http://llvm.org/bugs/show_bug.cgi?id=4579>
>
> Robert P.
>
In March, I was told to use --analyze command.  This was so by  
design.  May be things have changed since then.

~/clang-test-> clang --analyze test.c -o test
test.c:5:5: warning: Value stored to 'x' is never read
     x = x++;
     ^   ~~~
test.c:5:9: warning: Value stored to 'x' is never read
     x = x++;
         ^~~
test.c:4:5: warning: Branch condition evaluates to an uninitialized  
value.
     if ( x == -1 ) x = x/0;
     ^    ~
3 diagnostics generated.




More information about the cfe-dev mailing list