PASS: gcc (GCC) 4.4.7 20110810 (prerelease) FAIL: gcc (GCC) 4.5.4 20110810 (prerelease) FAIL: gcc (GCC) 4.6.2 20110810 (prerelease) FAIL: gcc (GCC) 4.7.0 20110810 (experimental) int *p; void f (void) { struct { int y; } x; *p = x.y; } -------------------------------------------------------------------------------- -c -Wall -O2 -------------------------------------------------------------------------------- PASS: 1.c: In function ‘f’: 1.c:5: warning: ‘x.y’ is used uninitialized in this function FAIL: <nothing>
We should have never accepted the aggregate warning code in 4.4 and earlier in it's current awkward form that only works for "testcases". It was removed. This is a dup of PR????.
I was searching for duplicates but I haven't found a close enough one without knowing GCC internals.
I have a patch to restore the warning for this toy testcase.
Thanks for a fix, FYI this is a reduced real world problem. During backporting of [patch] Implement core file's PID for s390* and ppc* http://sourceware.org/ml/binutils/2011-04/msg00272.html specifically misordered: vvv elf_tdata (abfd)->core_pid = psinfo.pr_pid; ^^^ memcpy (&psinfo, note->descdata, sizeof (psinfo)); I got a warning from RHEL-6 gcc-4.4.5-6.el6.x86_64 which I did not get the warning during the patch preparation on Fedora 14 gcc-4.5.1-4.fc14.x86_64. This problem was found and would be found afterwards anyway by a testcase but not every line of GCC compiled code has a testcase.
Author: rguenth Date: Thu Aug 11 14:28:36 2011 New Revision: 177667 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=177667 Log: 2011-08-11 Richard Guenther <rguenther@suse.de> PR middle-end/50040 * gimplify.c (gimplify_modify_expr_complex_part): Mark the load of the other piece with TREE_NO_WARNING. * tree-flow.h (warn_uninit): Adjust prototype. * tree-ssa.c (warn_uninit): Take uninitialized SSA name, the base variable and the expression that is used separately. Properly query all TREE_NO_WARNING flags. (struct walk_data): Remove. (warn_uninitialized_var): Likewise. (warn_uninitialized_vars): Do not walk gimple pieces but simply look at all SSA uses of the statement. Handle unused memory separately. * tree-ssa-uninit.c (warn_uninitialized_phi): Adjust. * g++.dg/warn/unit-1.C: Un-XFAIL. * gcc.dg/uninit-I.c: Likewise. Modified: trunk/gcc/ChangeLog trunk/gcc/gimplify.c trunk/gcc/testsuite/g++.dg/warn/unit-1.C trunk/gcc/testsuite/gcc.dg/uninit-I.c trunk/gcc/tree-flow.h trunk/gcc/tree-ssa-uninit.c trunk/gcc/tree-ssa.c
Fixed for 4.7 sofar.
*** Bug 50950 has been marked as a duplicate of this bug. ***
Patch doesn't apply to the 4.6 branch. Don't hold your breath.
*** Bug 50966 has been marked as a duplicate of this bug. ***
It's also questionable to cause new warnings to appear on the branch if you consider code using -Werror. Leaving open a bit for further consideration, should be closed as fixed for 4.7 once that is released and it didn't make the 4.6 branch.
*** Bug 51740 has been marked as a duplicate of this bug. ***
(In reply to comment #10) > It's also questionable to cause new warnings to appear on the branch if > you consider code using -Werror. gcc-4.4 used to warn (see bug 50950), therefore if someone's build is using -Werror and added such uninitialized vars to his code _after_ beginning to use gcc >= 4.5, he is not getting the error despite the fact that he wants to.
The 4.5 branch is being closed, adjusting target milestone.
The 4.6 branch has been closed, fixed in GCC 4.7.0.