Hi This is a simple example that should warn about uninitialized variable, but doesn't. Compile with -O2 -Wall: void a(void) { int *p1; *p1 = 3; } gcc-4.3 warned correctly in this case.
Confirmed. I see no technical reason for this.
Broken by Manu's PR179 changes: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=139347
Created attachment 18289 [details] gcc45-pr40943.patch Untested fix. It breaks uninit-6*.c again though, but "fixing" this kind of false positive by simply disabling uninitialized warnings for all pointer dereferences on LHS is IMHO too big hammer.
Since the alias-improvements branch merge uninitialized warnings for aggregates are seriously broken implementation wise anyway.
(In reply to comment #3) > Created an attachment (id=18289) [edit] > gcc45-pr40943.patch > > Untested fix. It breaks uninit-6*.c again though, but "fixing" this kind of > false positive by simply disabling uninitialized warnings for all pointer > dereferences on LHS is IMHO too big hammer. > I was testing the exactly same patch, you posted first, so the honor is yours. :-) Notice that you should not need -O2 for testing this. The testcase should work even with -O0. Notice that uninit-6 is a missed optimization. Even with -O2, the unreachable use of field is still present in the code shown by uninit-6-O0.c.136t.optimized, so it seems the tree optimizers do not handle this case. My patch only hide the symptom (the warning) but the missed optimization was still there so we could xfail it again.
Subject: Bug 40943 Author: jakub Date: Mon Aug 3 19:26:10 2009 New Revision: 150379 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=150379 Log: PR middle-end/40943 * tree-ssa.c (warn_uninitialized_var): Even on LHS warn for operand of INDIRECT_REF. * gcc.dg/uninit-6.c: Re-add XFAIL. * gcc.dg/uninit-6-O0.c: Likewise. * gcc.dg/uninit-pr40943.c: New test. Added: trunk/gcc/testsuite/gcc.dg/uninit-pr40943.c Modified: trunk/gcc/ChangeLog trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/gcc.dg/uninit-6-O0.c trunk/gcc/testsuite/gcc.dg/uninit-6.c trunk/gcc/tree-ssa.c
Subject: Bug 40943 Author: jakub Date: Mon Aug 3 19:27:32 2009 New Revision: 150380 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=150380 Log: PR middle-end/40943 * tree-ssa.c (warn_uninitialized_var): Even on LHS warn for operand of INDIRECT_REF. * gcc.dg/uninit-6.c: Re-add XFAIL. * gcc.dg/uninit-6-O0.c: Likewise. * gcc.dg/uninit-pr40943.c: New test. Added: branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/uninit-pr40943.c Modified: branches/gcc-4_4-branch/gcc/ChangeLog branches/gcc-4_4-branch/gcc/testsuite/ChangeLog branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/uninit-6-O0.c branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/uninit-6.c branches/gcc-4_4-branch/gcc/tree-ssa.c
Fixed.