<-- snip --> $ cat test.c int foo, bar; void decode_reloc(int reloc, int *is_alt) { if (reloc >= 20) *is_alt = 1; else if (reloc >= 10) *is_alt = 0; } void testfunc() { int alt_reloc; decode_reloc(foo, &alt_reloc); if (alt_reloc) bar = 42; } $ gcc -O2 -Wall -c test.c test.c: In function ‘testfunc’: test.c:17: warning: ‘alt_reloc’ is used uninitialized in this function $ <-- snip --> A "may be used uninitialized in this function" warning might be appropriate here, but gcc seems to wrongly think it can prove "alt_reloc" was for sure uninitialized here.
So Jump threading comes along and threads the jump for some reason makes the PHI node go away.
The warning works as designed, the PHI node in question that causes the warning only has a single incoming edge: testfunc () { int alt_reloc; int foo.0; <bb 2>: foo.0_1 = foo; if (foo.0_1 > 19) goto <bb 5>; else goto <bb 3>; <bb 3>: if (foo.0_1 > 9) goto <bb 6>; else goto <bb 4>; <bb 4>: if (alt_reloc_4(D) != 0) goto <bb 5>; else goto <bb 6>; <bb 5>: bar = 42; <bb 6>: return; } we don't check whether the uninitialized use post-dominates the function entry. I don't know if we should. This is just a case of 4.3 optimizing better than 4.2 which makes the warning less precise.
While this is a regression the underlying problem was latent and thus this should be an enhacement report. But I'll have a look.
Subject: Bug 35609 Author: rguenth Date: Wed Mar 19 10:44:52 2008 New Revision: 133341 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=133341 Log: 2008-03-19 Richard Guenther <rguenther@suse.de> PR middle-end/35609 * tree-ssa.c (always_executed): New global flag. (warn_uninitialized_var): If !always_executed warn with "maybe" instead of "is". (execute_early_warn_uninitialized): Compute post-dominators. Initialize always_executed before processing each basic block. * gcc.dg/testsuite/uninit-15.c: New testcase. * gcc.dg/testsuite/uninit-16.c: Likewise. Added: trunk/gcc/testsuite/gcc.dg/uninit-15.c trunk/gcc/testsuite/gcc.dg/uninit-16.c Modified: trunk/gcc/ChangeLog trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-ssa.c
Fixed on the trunk.
And on the branch.
Subject: Bug 35609 Author: rguenth Date: Tue Mar 25 10:09:22 2008 New Revision: 133507 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=133507 Log: 2008-03-25 Richard Guenther <rguenther@suse.de> Backport from mainline: 2008-03-19 Richard Guenther <rguenther@suse.de> PR middle-end/35609 * tree-ssa.c (walk_data): New structure. (warn_uninitialized_var): If not always_executed warn with "maybe" instead of "is". (execute_early_warn_uninitialized): Compute post-dominators. Initialize always_executed before processing each basic block. * gcc.dg/testsuite/uninit-15.c: New testcase. * gcc.dg/testsuite/uninit-16.c: Likewise. Added: branches/gcc-4_3-branch/gcc/testsuite/gcc.dg/uninit-15.c - copied unchanged from r133341, trunk/gcc/testsuite/gcc.dg/uninit-15.c branches/gcc-4_3-branch/gcc/testsuite/gcc.dg/uninit-16.c - copied unchanged from r133341, trunk/gcc/testsuite/gcc.dg/uninit-16.c Modified: branches/gcc-4_3-branch/gcc/ChangeLog branches/gcc-4_3-branch/gcc/testsuite/ChangeLog branches/gcc-4_3-branch/gcc/tree-ssa.c