[cfe-dev] uninitialized variable warning, etc
rdogra at earthlink.net
rdogra at earthlink.net
Thu Mar 5 18:36:52 PST 2009
given following code:
~/clang-test-> cat test.c
#include <stdio.h>
int main (void) {
int a = 0, b;
a = b + a;
printf ("a = %s", a);
return 0;
}
/clang-test-> gcc -Wall -Wno-switch -Wdisabled-optimization -Wpointer-
arith -Wredundant-decls -Wno-pointer-sign -Wcast-qual -Wwrite-strings -
O3 -fno-math-errno -std=c99 test.c
test.c: In function ‘main’:
test.c:8: warning: format ‘%s’ expects type ‘char *’, but argument 2
has type ‘int’
test.c:7: warning: ‘b’ is used uninitialized in this function
~/clang-test-> ccc -Wall -Wno-switch -Wdisabled-optimization -Wpointer-
arith -Wredundant-decls -Wno-pointer-sign -Wcast-qual -Wwrite-strings -
O3 -fno-math-errno -std=c99 test.c
~/clang-test-> gcc -Wall -std=c99 test.c test.c: In function ‘main’:
test.c:8: warning: format ‘%s’ expects type ‘char *’, but argument 2
has type ‘int’
~/clang-test-> gcc -Wall -O3 test.c
test.c: In function ‘main’:
test.c:8: warning: format ‘%s’ expects type ‘char *’, but argument 2
has type ‘int’
test.c:7: warning: ‘b’ is used uninitialized in this function
~/clang-test-> ccc -Wall -O3 -std=c99 test.c
~/clang-test->
Also clang warns on the following but gcc doesn't??
libavcodec/dsputil.c:177:8: warning: use of unary operator that may be
intended as compound assignment (-=)
end=-1;
^~
libavcodec/dsputil.c:3966:10: warning: use of unary operator that may
be intended as compound assignment (-=)
for(i=-len, j=len-1; i<0; i++, j--) {
^~
More information about the cfe-dev
mailing list