The man page of gcc states: -Wuninitialized Warn if an automatic variable is used without first being initial- ized or if a variable may be clobbered by a "setjmp" call.
These warnings are possible only in optimizing compilation, because they require data flow information that is computed only when opti- mizing. If you don't specify -O, you simply won't get these warn- ings. This limitation, while understandable from the implementation standpoint, has a nasty consequence: one cannot use -Wunitialized and debug at the same time, because the -O very efficiently destroys information that is needed for debugging (such as being able to display local variables). The above triplets are for Apple's gcc 4.0.0, but that is irrelevant, the same thing happens on every gcc platform. In effect, this means that one needs to do two separate compiles while debugging a program: a "warnings" compile and a "debugging" compile. Suggestion: if the -Wunitialized is specified (and no -O), do just enough data flow analysis to perform the analysis required for the -Wunitialized, but abstain from doing anything that breaks debuggability. -- Summary: do not require -O for -Wunitialized Product: gcc Version: 4.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: jhi at iki dot fi GCC build triplet: powerpc-apple-darwin8 GCC host triplet: powerpc-apple-darwin8 GCC target triplet: powerpc-apple-darwin8 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29199