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

--- Comment #11 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Jason Merrill
<ja...@gcc.gnu.org>:

https://gcc.gnu.org/g:32bd8a1053d25cbb15172294e59a81bc134658aa

commit r11-11162-g32bd8a1053d25cbb15172294e59a81bc134658aa
Author: Jason Merrill <ja...@redhat.com>
Date:   Sun Jun 4 12:00:55 2023 -0400

    c++: NRV and goto [PR92407]

    Here our named return value optimization was breaking the required
    destructor when the goto takes 'a' out of scope.  A simple fix for the
    release branches is to disable the optimization in the presence of backward
    goto.

    We could do better by disabling the optimization only if there is a
backward
    goto across the variable declaration, but we don't track that, and in GCC
14
    we instead make the goto work with NRV.

            PR c++/92407

    gcc/cp/ChangeLog:

            * cp-tree.h (struct language_function): Add backward_goto.
            * decl.c (check_goto): Set it.
            * typeck.c (check_return_expr): Prevent NRV if set.

    gcc/testsuite/ChangeLog:

            * g++.dg/opt/nrv22.C: New test.

    (cherry picked from commit a645347c19b07cc7abd7bf276c6769fc41afc932)
  • [Bug c++/92407] Destruction of ... cvs-commit at gcc dot gnu.org via Gcc-bugs

Reply via email to