From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 9E1653858D33; Tue, 7 Feb 2023 21:01:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9E1653858D33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1675803689; bh=JpGdBI9Jw3puwZuBFM44KJpYn1Wt+G+98wkw6vrSESE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=B0JdlmXQ8KwHAW3katE2LacqSrNHRkKPBqiPPQLKRKzuLMtJklo56UTh/s4xmblQK G85ePQ/1U0BttCbdxHvfrarkPuMj/osdwcbSMPPgRf9AXmrbCCxy9VPpYLetDt+Dki s87SuLUbeOD8Tf9ByMocX+AzErp51cl0ZZsOOTYk= From: "mpolacek at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/107079] [10/11/12/13 Regression] ICE initializing lifetime-extended constexpr variable that stores its this pointer Date: Tue, 07 Feb 2023 21:01:28 +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: 13.0 X-Bugzilla-Keywords: ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: mpolacek at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 10.5 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=3D107079 --- Comment #4 from Marek Polacek --- The ICE could be fixed with --- a/gcc/cp/call.cc +++ b/gcc/cp/call.cc @@ -13604,9 +13604,13 @@ set_up_extended_ref_temp (tree decl, tree expr, vec **cleanups, init =3D NULL_TREE; } else - /* Create the INIT_EXPR that will initialize the temporary - variable. */ - init =3D split_nonconstant_init (var, expr); + { + /* Create the INIT_EXPR that will initialize the temporary + variable. */ + init =3D split_nonconstant_init (var, expr); + replace_placeholders (init, var); + } + if (at_function_scope_p ()) { add_decl_expr (var); but it'll result in error: modification of =E2=80=98=E2=80=99 is not a constant expr= ession because the INIT_EXPR is _ZGR1x_.x =3D (const struct X *) &_ZGR1x_ but _ZGR1x_ isn't in our constexpr context.=