https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77448

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING
   Last reconfirmed|                            |2016-09-02
     Ever confirmed|0                           |1

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Why do you think this is incorrect code.  This is a called named return value
optimization.  See https://en.wikipedia.org/wiki/Return_value_optimization .
This is a way to reduce the number of copy constructors being used.
The reason why it is the first argument is because the return value is passed
via a pointer as the first argument (the rest of the arguments are shifted over
by 1 register); this is the x86_64 ABI (AARCH64 ABI is different and the
pointer would have been passed in via a different register and the arguments
registers would stay the same).

Reply via email to