• Re: g++ 14 new feature bug

    From Andrey Tarasevich@21:1/5 to Bonita Montero on Sun Oct 6 13:00:33 2024
    On 10/06/24 9:22 AM, Bonita Montero wrote:
    g++ 14 has a new feature which that warns when a return value
    optimization / copy elision doesn't take place. Here's my example:

    https://godbolt.org/z/G8Eh1hrsd

    As you can see the compiler warns twice - but moves according to
    the program output nevertheless. Is this a bug ?

    NRVO (which is what the option name refers to) is not about moving
    instead of copying. It is about eliminating the named local object
    entirely, effectively transforming it into a reference to the
    caller-owned recipient object. In case of NRVO the result is constructed directly in the external recipient object.

    In your case the NRVO does not happen. Hence the warning.

    --
    Best regards,
    Andrey

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)