In the following example gcc should be able to prove that x may be uninitialized, but it does not warn. $ gcc-4.8 -c -O2 -Wmaybe-uninitialized example.c $ cat example.c int f(void); int g(void) { int x; if (f()) x = 1; return x; } With -O2 the generated code actually unconditionally returns 1 and discards the return value of f(). This is something the compiler can and should warn about when specifically asked to. $ gcc-4.8 -S -fno-asynchronous-unwind-tables -O2 -Wmaybe-uninitialized example.c $ cat example.s .file "example.c" .text .p2align 4,,15 .globl g .type g, @function g: subl $12, %esp call f movl $1, %eax addl $12, %esp ret .size g, .-g .ident "GCC: (GNU) 4.8.0" .section .note.GNU-stack,"",@progbits
Dup *** This bug has been marked as a duplicate of bug 18501 ***