From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 89A3338460A2; Fri, 3 May 2024 20:01:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 89A3338460A2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1714766503; bh=O2tPHFvfhz/aEo2Vxh6zpBL6Ms+h9Obyt+gIKt34OFE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Oz17vamwJHzc/NlmAAD4XORDPdBvfTpPrNVFO9Qy71v17rWtEpIGYrdU4eVZuN0Hj ZKd//uwgQqbllMjBIwJIVkpcHhL2ujJ8sD+g282YDIcvEybRgW7rPqNhIkIbqVOM24 EqL2+hzj8dmc2u3bU2SYAFF7kH0O41u+FHAQhP5w= 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:43 +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 #3 from GCC Commits --- The releases/gcc-14 branch has been updated by Jason Merrill : https://gcc.gnu.org/g:3b4d6b6ecd79df790bf0938dab1f51094f94d777 commit r14-10165-g3b4d6b6ecd79df790bf0938dab1f51094f94d777 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. (cherry picked from commit 8f3afb83c879f1bfa722a963a07c06aaf174ef72)=