This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Missing warning about uninitialized variable.


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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]