public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/92407] Destruction of objects returned from functions skipped by goto
Date: Wed, 07 Jun 2023 01:33:41 +0000	[thread overview]
Message-ID: <bug-92407-4-Y0AMRvLn4H@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-92407-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Jason Merrill <jason@gcc.gnu.org>:

https://gcc.gnu.org/g:7e0b65b239c3a0d68ce94896b236b03de666ffd6

commit r14-1593-g7e0b65b239c3a0d68ce94896b236b03de666ffd6
Author: Jason Merrill <jason@redhat.com>
Date:   Sun Jun 4 12:09:11 2023 -0400

    c++: enable NRVO from inner block [PR51571]

    Our implementation of the named return value optimization has been limited
    to variables declared in the outermost block of the function, to avoid
    needing to handle the case where the variable needs to be destroyed due to
    going out of scope.  PR92407 pointed out a case we were missing, where the
    variable goes out of scope due to a goto and we were failing to destroy it.

    It occurred to me that this problem is the flip side of PR33799, where we
    need to be sure to destroy the return value if a cleanup throws on return;
    here we want to avoid destroying the return value when exiting the
    variable's scope on return.  We can use the same flag to indicate to both
    cleanups that we're returning.

    This implements the guaranteed copy elision specified by P2025 (which is
not
    yet part of the draft standard).

            PR c++/51571
            PR c++/92407

    gcc/cp/ChangeLog:

            * decl.cc (finish_function): Simplify NRV handling.
            * except.cc (maybe_set_retval_sentinel): Also set if NRV.
            (maybe_splice_retval_cleanup): Don't add the cleanup region
            if we don't need it.
            * semantics.cc (nrv_data): Add simple field.
            (finalize_nrv): Set it.
            (finalize_nrv_r): Check it and retval sentinel.
            * cp-tree.h (finalize_nrv): Adjust declaration.
            * typeck.cc (check_return_expr): Remove named_labels check.

    gcc/testsuite/ChangeLog:

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

  parent reply	other threads:[~2023-06-07  1:33 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-92407-4@http.gcc.gnu.org/bugzilla/>
2020-11-16 16:13 ` sichert at in dot tum.de
2023-06-06  1:51 ` jason at gcc dot gnu.org
2023-06-07  1:33 ` cvs-commit at gcc dot gnu.org
2023-06-07  1:33 ` cvs-commit at gcc dot gnu.org [this message]
2023-06-07  1:35 ` jason at gcc dot gnu.org
2023-08-31 22:40 ` cvs-commit at gcc dot gnu.org
2023-12-20 17:41 ` cvs-commit at gcc dot gnu.org
2023-12-20 17:46 ` jason at gcc dot gnu.org
2024-01-24 19:40 ` cvs-commit at gcc dot gnu.org
2024-02-05 18:20 ` jason at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-92407-4-Y0AMRvLn4H@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).