the following code does'nt produce any warning when compiled with "-Wall" option in gcc:
int main ()
{
int c, i;
for ( ; i < 10; i++ ) {
c += i;
}
return c;
}
This is the command used to build the source:
$ gcc -c -Wall 1.c
$
It returns without any message. I would expect a "warning: ‘i’ is used uninitialized in this function", and the same warning for the 'c' variable.
Any idea about this behavior? Thank you.
Analysis performed by -Wall
is very limited without optimizations. Warning is successfully detected with -O1
or -O2
.