Hello,
I suspect a regression in uninitialized value detection, but before
opening a bug I request your advices on the following problem:
I build the following code :
----------------------------------------------------
#include <stdio.h>
#include <stdlib.h>
int main( int argc, char **argv )
{
int j;
int rtn;
int k,t;
j = atoi( argv[1] );
if ( j > 5 )
{
rtn = 10;
}
k=t;
printf("rtn = %d\n", rtn);
exit(0);
}
----------------------------------------------------
With gcc 4.0:
bash-4.2$ gcc-4.0 -O2 -Wall ./test_gcc2.c -o test_gcc
./test_gcc2.c: In function 'main':
./test_gcc2.c:17: warning: 't' is used uninitialized in this function
./test_gcc2.c:7: warning: 'rtn' may be used uninitialized in this function
With gcc 4.6.1, the warning on rtn disappears :
bash-4.2$ gcc -O2 -Wall ./test_gcc2.c -o test_gcc
./test_gcc2.c: In function ‘main’:
./test_gcc2.c:8:8: attention : variable ‘k’ set but not used
[-Wunused-but-set-variable]
./test_gcc2.c:17:5: attention : ‘t’ is used uninitialized in this
function [-Wuninitialized]
Do I need to pass special options to gcc 4.6.1 to enable this
detection or is it a gcc problem ?
Regards
Patrice