Compiling the following code does not produce any warning, even if the "ret" variable would be used uninitialized in most cases: #include <stdio.h> int main(void) { int ret; printf("Input something: "); fflush(stdout); int c = getchar(); switch (c) { case 'a': ret = 0; break; default: /* ret still uninitialized. */ break; } return ret; } Compiled with "gcc -Wall -o uninitialized uninitialized.c" under GCC 4.5.2.
As of: gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) the following code also does not get warned about the possibly uninitialized variable. I'm quite sure that gcc *used* to pick this up. int main(int argc, char **argv) { int c; if (argc > 1) { c = 1; } return(c); }
This is constant propagation. Old issue. No fix in sight. *** This bug has been marked as a duplicate of bug 18501 ***