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
Status: RESOLVED FIXED
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
URL:
Keywords:
: 50950 50966 51740 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-08-10 19:29 UTC by Jan Kratochvil
Modified: 2013-04-12 16:17 UTC (History)
2 users (show)

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


Attachments

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
--------------------------------------------------------------------------------
PASS:
1.c: In function ‘f’:
1.c:5: warning: ‘x.y’ is used uninitialized in this function
FAIL:
<nothing>
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*
  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.
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
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
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.