[Bug c++/23372] [4.0/4.1 Regression] Temporary aggregate copy not elided when passing parameters by value

guillaume dot melquiond at ens-lyon dot fr gcc-bugzilla@gcc.gnu.org
Sun Aug 14 06:45:00 GMT 2005


------- Additional Comments From guillaume dot melquiond at ens-lyon dot fr  2005-08-14 06:45 -------
Looking at it again, I found an even worse regression with respect to g++ 3.4.
Consider this testcase:

struct A { int a[1000]; }
A f();
void g(A);
void h() { g(f()); }

Ideally, h will allocate a stack frame for g and ask f to directly dump its
result in it. No temporary nor memcpy will be used at all. g++ 3.4 behaves this way.

g++ 4.0 however will first allocate some space for the result of f, then call f
and copy its result in another temporary, and finally it will allocate the stack
frame for g and copy the temporary in it. Two temporaries and two memcpys are
needed for g++ 4.0.

So the same issue arises when returning a result by value.

-- 


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



More information about the Gcc-bugs mailing list