Bug 31841

Summary: [4.2 regression] bogus is used uninitialized (warning in dead code)
Product: gcc Reporter: Sylvain Pion <pion.sylvain>
Component: middle-endAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: normal CC: fang, gcc-bugs, Laurent.Rineau__gcc, manu
Priority: P3 Keywords: diagnostic
Version: 4.2.0   
Target Milestone: 4.3.0   
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
Bug Depends on:    
Bug Blocks: 24639    

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.