[Bug c++/16405] [3.4/4.0 Regression] Temporary aggregate copy not elided

giovannibajo at libero dot it gcc-bugzilla@gcc.gnu.org
Thu Oct 7 11:51:00 GMT 2004


------- Additional Comments From giovannibajo at libero dot it  2004-10-07 11:51 -------
Confirmed. This won't probably be fixed in the 3.4 branch, but it should in 4.0 
at least. 

Testcase (same of original description):
------------------------------------
struct T {
  int a[128];
  T &operator+=(T const &v);
  T operator+(T const &v) const { T t = *this; t += v; return t; }
};

extern T a, b, c;
void f() { a = b + c; }
------------------------------------


The optimized dump (without the copy constructor) from mainline is:

------------------------------------
void f() ()
{
  struct T t;
  struct T * const this;
  struct T & v;
  struct T * D.1598;
  struct T D.1594;
  struct T t;

<bb 0>:
  t = b;
  operator+= (&t, &c);
  D.1594 = t;
  a = D.1594;
  return;

}
------------------------------------

So there is one additional temporary which is not removed.

I cannot see a regression anymore with the copy constructor, so this bug only 
tracks this now. Guillaume, if you still see a regression with the copy 
constructor please open a new bug report. It is wrong to track two different 
testcases (although similar) in the same report.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |giovannibajo at libero dot
                   |                            |it
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
      Known to fail|                            |3.4.3 4.0.0
      Known to work|                            |3.3.4
   Last reconfirmed|0000-00-00 00:00:00         |2004-10-07 11:51:22
               date|                            |
            Summary|Non optimized code when     |[3.4/4.0 Regression]
                   |using default copy          |Temporary aggregate copy not
                   |constructor                 |elided
   Target Milestone|---                         |3.4.3


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16405



More information about the Gcc-bugs mailing list