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

--- Comment #9 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-15 branch has been updated by Iain D Sandoe
<ia...@gcc.gnu.org>:

https://gcc.gnu.org/g:f67c851f03cf14c82a43045ea567ab5fb06377ac

commit r15-10106-gf67c851f03cf14c82a43045ea567ab5fb06377ac
Author: Iain Sandoe <i...@sandoe.co.uk>
Date:   Wed Jul 23 16:22:32 2025 +0100

    c++, coroutines: Handle allocation fail returns [PR121219].

    The current implementation was returning the result of the g_r_o_o_a_f
    call independently of the return expressions for 'normal' cases.

    This prevents the NVRO that we need to guarantee copy elision for the
    ramp return values - when these are initialised from a temporary of the
    same type.

    The solution here reorders the code so that the regular return expression
    appears before the allocation-failed case.  Ensure that the g_r_o and
    associated code appears in a distinct scope.  These steps are to meet the
    constaints of NRV.

            PR c++/121219

    gcc/cp/ChangeLog:

            * coroutines.cc
            (cp_coroutine_transform::build_ramp_function): Reorder the return
            expressions for the 'normal' and 'allocation failed' cases so that
            NRV constraints are met.

    gcc/testsuite/ChangeLog:

            * g++.dg/coroutines/torture/pr121219.C: New test.

    Signed-off-by: Iain Sandoe <i...@sandoe.co.uk>
    (cherry picked from commit a2775feb7c7de9f21f79052e2b6a752a3eb08f07)

Reply via email to