gcc failing to warn of uninitialized variable
问题 The following code has a variable that may be uninitialized. It seems that gcc should be generating a warning but isn\'t: $ cat a.c int foo(int b) { int a; if (b) a = 1; return a; } $ gcc-4.7 -c -Wall -Wmaybe-uninitialized -o a.o ./a.c $ gcc-4.7 -v Using built-in specs. COLLECT_GCC=gcc-4.7 COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.7/lto-wrapper Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion=\'Ubuntu/Linaro 4.7.3-2ubuntu1~12.04\' --with-bugurl=file://