Re: Missing warning about uninitialized variable.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Mikael Vidstedt wrote:
Just a quick question: Did anybody actually read the subject? My question
was not about the value of the variable, it was about recent GCC versions no
longer warn about the use of an uninitialized variable...?

You have to turn on the optimizer to see that. As I understand it, it's only when the optimizer walks down the tree that it picks up the uninitialized bit.

-bash-3.00$ gcc -O -Wall -c warn.c
warn.c: In function `main':
warn.c:4: warning: 'g' might be used uninitialized in this function
-bash-3.00$ cat warn.c
#include <stdio.h>
int main(int argc, char **argv)
{
 int g;
 if (argc == 10) { g = 3; }
 printf("g == %d\n", g);
 return 0;
}

Tom

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux