Bug 31841 - [4.2 regression] bogus is used uninitialized (warning in dead code)
Summary: [4.2 regression] bogus is used uninitialized (warning in dead code)
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.2.0
: P3 normal
Target Milestone: 4.3.0
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks: Wuninitialized
  Show dependency treegraph
 
Reported: 2007-05-05 17:28 UTC by Sylvain Pion
Modified: 2009-03-30 21:46 UTC (History)
4 users (show)

See Also:
Host: i686-pc-linux-gnu
Target:
Build:
Known to work: 4.3.0
Known to fail: 4.2.3 4.2.5
Last reconfirmed: 2009-02-09 16:06:14


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sylvain Pion 2007-05-05 17:28:31 UTC
Compiling the code below with -O2 -Wall produces the buggy warning
mentionned in the subject.
g++ 4.1 and 4.3 do not have this problem.

The code below is pretty minimal (extracted from CGAL).
For example, removing the derivation from the Empty_class
removes the buggy warning.

----------------
struct Empty_class {};

struct C : Empty_class {};

struct M {
  static C f() { return C(); }
};

struct R {
  C c;

  R() 
    : c(M::f()) {}
};

int main()
{
  R r;
  return 0;
}
--------------------
Comment 1 Richard Biener 2007-05-05 19:19:07 UTC
int main() ()
{
  struct Empty_class * this.0;
  struct Empty_class * const this;
  struct C * D.2077;
  struct R r;
  int D.2064;

<bb 2>:
  D.2077_1 = &r.c;
  this.0_3 = this.0_2;
  this.0_4 = (struct Empty_class *) D.2077_1;
  D.2064_5 = 0;
  return D.2064_5;

}

somehow inlining ends up with the unused copies.
Comment 2 Manuel López-Ibáñez 2009-02-09 16:06:14 UTC
This works in GCC 4.1, 4.3 and 4.4, so this is either a regression (that probably will not be fixed before 4.2 is closed) or it is not a regression and should be closed as FIXED already in trunk.
Comment 3 Joseph S. Myers 2009-03-30 21:46:59 UTC
Closing 4.2 branch, fixed in 4.3.