extern int foo (int); int foo (int c) { int res; if (c) res = 0; return res; } res may be used uninitialized if c==0, but the function is "optimized" to "return 0" before the uninit1 warning pass runs.
It's conditionally uninitialized and thus only warned in late uninit pass. This is a known issue of optimistic constant propagation. Duplicate of PRxyz. Never going to be fixed.
PR18501, the most frequently reported Wuninitialized bug.
PR18501, the most frequently reported Wuninitialized bug. Of course, it is possible to fix it. Clang does warn: pr18501.c:5:7: warning: variable 'res' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized] if (c) ^ pr18501.c:7:10: note: uninitialized use occurs here return res; ^~~ pr18501.c:5:3: note: remove the 'if' if its condition is always true if (c) ^~~~~~ pr18501.c:4:10: note: initialize the variable 'res' to silence this warning int res; ^ = 0 1 warning generated. It is just that it probably needs some serious amount of work.