This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/23372] [4.0/4.1 Regression] Temporary aggregate copy not elided when passing parameters by value
- From: "guillaume dot melquiond at ens-lyon dot fr" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 14 Aug 2005 06:45:51 -0000
- Subject: [Bug c++/23372] [4.0/4.1 Regression] Temporary aggregate copy not elided when passing parameters by value
- References: <20050813080257.23372.guillaume.melquiond@ens-lyon.fr>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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