This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: gcc 3.0.1 & C++ ABI issues
>>>>> "Gabriel" == Gabriel Dos Reis <gdosreis@sophia.inria.fr> writes:
> Oh, sorry I messed up things. What I had in mind is actually
> template<typename _Tp>
> inline complex<_Tp>
> operator-(const complex<_Tp>& __x, const _Tp& __y)
> { return complex<_Tp> (__x) -= __y; }
> In an old discussion we had on comp.lang.c++.moderated, it was agreed
> (if my memory serves me correctly) that if the above is written to use a
> local variable, then it would be more efficient because "return"
> will return what -= returns.
Yes, that's true; as written above, it would need to do a copy.
> | > | inline A f (A a) { return a; }
> | > |
> | > | int main ()
> | > | {
> | > | A a1 = f (A ());
> | > | }
> | > |
...
> | The copy constructor I see is for copying the parameter 'a' into the return
> | value of f. 'a' is not a temporary, it is a parameter
> Aha, thanks for the clarification. But isn't the parameter 'a'
> considered a local variable to f for the purpose of expression
> evaluation?
No; it is created and destroyed in the caller.
IMO, optimizing this case is not important anyway; who passes complex
objects by value?
Jason