From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 99CD9385840D; Mon, 25 Oct 2021 08:27:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 99CD9385840D From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/102921] error: modification of '' is not a constant expression Date: Mon, 25 Oct 2021 08:27:51 +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: X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub 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 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: Mon, 25 Oct 2021 08:27:51 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102921 --- Comment #3 from Jakub Jelinek --- --- gcc/cp/call.c.jj 2021-10-21 16:06:42.231940456 +0200 +++ gcc/cp/call.c 2021-10-25 10:20:00.970635564 +0200 @@ -12735,7 +12735,9 @@ set_up_extended_ref_temp (tree decl, tre /* If the initializer is constant, put it in DECL_INITIAL so we get static initialization and use in constant expressions. */ - init =3D maybe_constant_init (expr); + init =3D maybe_constant_init (expr, NULL_TREE, + VAR_P (decl) + && DECL_DECLARED_CONSTEXPR_P (decl)); /* As in store_init_value. */ init =3D cp_fully_fold (init); if (TREE_CONSTANT (init)) makes this accepted, but not the PR101588 testcase.=