https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104415
Bug ID: 104415 Summary: uninit diagnostic improvement at -O0 Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: rguenth at gcc dot gnu.org Target Milestone: --- For int foo () { int cond = 1; int tem; return cond ? tem : 0; } we emit t.c: In function 'foo': t.c:5:21: warning: 'tem' may be used uninitialized [-Wmaybe-uninitialized] 5 | return cond ? tem : 0; | ~~~~~~~~~~~^~~ t.c:4:7: note: 'tem' was declared here 4 | int tem; | ^~~ when not optimizing but t.c: In function 'foo': t.c:5:21: warning: 'tem' is used uninitialized [-Wuninitialized] 5 | return cond ? tem : 0; | ~~~~~~~~~~~^~~ t.c:4:7: note: 'tem' was declared here 4 | int tem; | ^~~ when optimizing. Even when not optimizing we could figure out the condition is constant and emit the "is used uninitialized" variant.