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++/96090] noexcept operator of potentially-throwing defaulted function gives the wrong result
Date: Mon, 11 Dec 2023 02:34:30 +0000	[thread overview]
Message-ID: <bug-96090-4-VprtOjTngV@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-96090-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Nathaniel Shead <nshead@gcc.gnu.org>:

https://gcc.gnu.org/g:4719b6f5ae4d758f193a17bbd5fb6cbacd702a23

commit r14-6395-g4719b6f5ae4d758f193a17bbd5fb6cbacd702a23
Author: Nathaniel Shead <nathanieloshead@gmail.com>
Date:   Sat Oct 28 16:04:52 2023 +1100

    c++: Fix noexcept checking for trivial operations [PR96090]

    This patch stops eager folding of trivial operations (construction and
    assignment) from occurring when checking for noexceptness. This was
    previously done in PR c++/53025, but only for copy/move construction,
    and the __is_nothrow_xible builtins did not receive the same treatment
    when they were added.

    To handle `is_nothrow_default_constructible`, the patch also ensures
    that when no parameters are passed we do value initialisation instead of
    just building the constructor call: in particular, value-initialisation
    doesn't necessarily actually invoke the constructor for trivial default
    constructors, and so we need to handle this case as well.

    This is contrary to the proposed resolution of CWG2820; for now we just
    ensure it matches the behaviour of the `noexcept` operator and create
    testcases formalising this, and if that issue gets accepted we can
    revisit.

            PR c++/96090
            PR c++/100470

    gcc/cp/ChangeLog:

            * call.cc (build_over_call): Prevent folding of trivial special
            members when checking for noexcept.
            * method.cc (constructible_expr): Perform value-initialisation
            for empty parameter lists.
            (is_nothrow_xible): Treat as noexcept operator.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp0x/noexcept81.C: New test.
            * g++.dg/ext/is_nothrow_constructible7.C: New test.
            * g++.dg/ext/is_nothrow_constructible8.C: New test.

    Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>

  parent reply	other threads:[~2023-12-11  2:34 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-07  0:22 [Bug c++/96090] New: Inconsistent querying of differring exception specifications of explicitly defaulted functions johelegp at gmail dot com
2020-07-07  7:25 ` [Bug c++/96090] " redi at gcc dot gnu.org
2021-08-29  0:17 ` [Bug c++/96090] noexcept operator of potentially-throwing defaulted function gives the wrong result johelegp at gmail dot com
2023-10-28  8:23 ` nathanieloshead at gmail dot com
2023-12-11  2:34 ` cvs-commit at gcc dot gnu.org [this message]
2024-02-06 14:42 ` mpolacek 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-96090-4-VprtOjTngV@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).