Bug 50040 - [4.6 Regression] missed warning: ‘x.y’ is used uninitialized in this function
Summary: [4.6 Regression] missed warning: ‘x.y’ is used uninitialized in this function
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.5.4
: P2 minor
Target Milestone: 4.7.0
Assignee: Richard Biener
: 50950 50966 51740 (view as bug list)
Depends on:
Reported: 2011-08-10 19:29 UTC by Jan Kratochvil
Modified: 2013-04-12 16:17 UTC (History)
3 users (show)

See Also:
Target: x86_64-unknown-linux-gnu
Known to work: 4.7.0
Known to fail:
Last reconfirmed: 2011-08-11 00:00:00


Note You need to log in before you can comment on or make changes to this bug.
Description Jan Kratochvil 2011-08-10 19:29:39 UTC
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
1.c: In function ‘f’:
1.c:5: warning: ‘x.y’ is used uninitialized in this function
Comment 1 Richard Biener 2011-08-11 10:04:06 UTC
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????.
Comment 2 Jan Kratochvil 2011-08-11 10:41:30 UTC
I was searching for duplicates but I haven't found a close enough one without knowing GCC internals.
Comment 3 Richard Biener 2011-08-11 10:58:07 UTC
I have a patch to restore the warning for this toy testcase.
Comment 4 Jan Kratochvil 2011-08-11 11:22:41 UTC
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*
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.
Comment 5 Richard Biener 2011-08-11 14:28:39 UTC
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
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
	* tree-ssa-uninit.c (warn_uninitialized_phi): Adjust.

	* g++.dg/warn/unit-1.C: Un-XFAIL.
	* gcc.dg/uninit-I.c: Likewise.

Comment 6 Richard Biener 2011-08-11 14:28:59 UTC
Fixed for 4.7 sofar.
Comment 7 Richard Biener 2011-11-02 09:49:45 UTC
*** Bug 50950 has been marked as a duplicate of this bug. ***
Comment 8 Richard Biener 2011-11-03 15:14:38 UTC
Patch doesn't apply to the 4.6 branch.  Don't hold your breath.
Comment 9 Richard Biener 2012-01-03 13:28:07 UTC
*** Bug 50966 has been marked as a duplicate of this bug. ***
Comment 10 Richard Biener 2012-01-03 13:29:56 UTC
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.
Comment 11 Richard Biener 2012-01-03 15:16:57 UTC
*** Bug 51740 has been marked as a duplicate of this bug. ***
Comment 12 Ozkan Sezer 2012-01-03 16:54:00 UTC
(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.
Comment 13 Richard Biener 2012-07-02 11:38:52 UTC
The 4.5 branch is being closed, adjusting target milestone.
Comment 14 Jakub Jelinek 2013-04-12 16:17:46 UTC
The 4.6 branch has been closed, fixed in GCC 4.7.0.