From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 54E013844763; Fri, 3 May 2024 20:01:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 54E013844763 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1714766467; bh=DpGRCZpeH8SfshkfaAS2zim295QInIwpWhIjFFlE1p4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=iBGjAZrw7ilB2XkRxpivqp06R3T0q49Q9FaUtayrAlyVajpsByPwDysLSfqzVlPU9 5A1mv+ngbhgi32qDsiL17/Ws0hTTs5oOKH/qAFY3xddEwZI4VEMigBJa3/2cZflVix VKeXP1mSwDg/gtep24rrNX2uOCFms+URhseuFBZk= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/114935] [14/15 regression] Miscompilation of initializer_list in presence of exceptions since r14-1705-g2764335bd336f2 Date: Fri, 03 May 2024 20:01:06 +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: 14.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: P1 X-Bugzilla-Assigned-To: jason at gcc dot gnu.org X-Bugzilla-Target-Milestone: 14.0 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=3D114935 --- Comment #2 from GCC Commits --- The trunk branch has been updated by Jason Merrill : https://gcc.gnu.org/g:8f3afb83c879f1bfa722a963a07c06aaf174ef72 commit r15-138-g8f3afb83c879f1bfa722a963a07c06aaf174ef72 Author: Jason Merrill Date: Fri May 3 09:52:46 2024 -0400 c++: initializer_list and EH [PR114935] When we initialize an array of a type with a non-trivial destructor, su= ch as the backing array for the initializer_list, we have a cleanup to destroy any constructed elements if a later constructor throws. When the array bei= ng created is a variable, the end of that EH region naturally coincides wi= th the beginning of the EH region for the cleanup for the variable as a wh= ole. But if the array is a temporary, or a subobject of one, the array clean= up region lasts for the rest of the full-expression, along with the normal cleanup for the TARGET_EXPR. As a result, when tata throws we clean it= up twice. Before r14-1705 we avoided this by disabling the array cleanup = in split_nonconstant_init, but after that we don't go through split_nonconstant_init, so let's handle it in cp_genericize_target_expr. PR c++/114935 gcc/cp/ChangeLog: * cp-gimplify.cc (cp_genericize_init): Add flags parm. (cp_genericize_init_expr): Pass nullptr. (cp_genericize_target_expr): Handle cleanup flags. * typeck2.cc (build_disable_temp_cleanup): Factor out of... (split_nonconstant_init): ...here. * cp-tree.h (build_disable_temp_cleanup): Declare. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/initlist-eh1.C: New test.=