From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 728773857839; Mon, 11 Dec 2023 02:34:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 728773857839 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1702262072; bh=+dHv5HVTrDRTkqK/W7ShyXh1mq2QjQ804hi7XmlEKVw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=mozDQ3JaN5Lieb8Fb0QVkP+JgtjPjvyQOV48d6+FBc1fBzykVbciNPJ7/BZF8qALm 7g5XeLNf4bt+uU73S9/giXmeRyMgEp8ysSYrEoZzaNayXwVC3dIR/W9PQ2g9FUZ0Pn 1jSfKHeDkDFlEX1ZeM7sxXHVb0J0d6cB+x36oeio= From: "cvs-commit at gcc dot 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 10.1.0 X-Bugzilla-Keywords: rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D96090 --- Comment #3 from GCC Commits --- The master branch has been updated by Nathaniel Shead : https://gcc.gnu.org/g:4719b6f5ae4d758f193a17bbd5fb6cbacd702a23 commit r14-6395-g4719b6f5ae4d758f193a17bbd5fb6cbacd702a23 Author: Nathaniel Shead 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 =