From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 22B2B3857C70; Sat, 8 Jan 2022 02:03:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 22B2B3857C70 From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/100588] Destroying delete shouldn't be called if constructor throws Date: Sat, 08 Jan 2022 02:03:54 +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: 11.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: jason 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 08 Jan 2022 02:03:55 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D100588 --- Comment #1 from CVS Commits --- The master branch has been updated by Jason Merrill : https://gcc.gnu.org/g:75047f795111150fd10a8f86f5c72deab10cde77 commit r12-6380-g75047f795111150fd10a8f86f5c72deab10cde77 Author: Jason Merrill Date: Thu Jan 6 13:26:21 2022 -0500 c++: destroying delete, throw in new-expr [PR100588] The standard says that a destroying operator delete is preferred, but t= hat only applies to the delete-expression, not the cleanup if a new-express= ion initialization throws. As a result of this patch, several of the destroying delete tests don't get EH cleanups, but I'm turning off the warning in cases where the initialization can't throw anyway. It's unclear what should happen if the class does not declare a non-deleting operator delete; a proposal in CWG was to call the global delete, which makes sense to me if the class doesn't declare its own operator new. I= f it does, we warn and don't call any deallocation function if initialization throws. PR c++/100588 gcc/cp/ChangeLog: * call.c (build_op_delete_call): Ignore destroying delete if alloc_fn. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/destroying-delete5.C: Expect warning. * g++.dg/cpp2a/destroying-delete6.C: New test.=