From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 043093861925; Fri, 5 Mar 2021 16:43:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 043093861925 From: "ppalka at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/96330] Constexpr variables cannot be used in the template context. Date: Fri, 05 Mar 2021 16:43:45 +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: 10.1.0 X-Bugzilla-Keywords: rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: ppalka at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED 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: Fri, 05 Mar 2021 16:43:46 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D96330 --- Comment #2 from Patrick Palka --- (In reply to Jakub Jelinek from comment #1) > Tried > --- gcc/cp/pt.c.jj 2020-07-27 10:38:19.000000000 +0200 > +++ gcc/cp/pt.c 2020-07-27 17:25:09.748240198 +0200 > @@ -16838,14 +16838,17 @@ tsubst_copy (tree t, tree args, tsubst_f > case TEMPLATE_ID_EXPR: > { > /* Substituted template arguments */ > - tree fn =3D TREE_OPERAND (t, 0); > + tree expr =3D TREE_OPERAND (t, 0); > tree targs =3D TREE_OPERAND (t, 1); >=20=20 > - fn =3D tsubst_copy (fn, args, complain, in_decl); > + expr =3D tsubst_copy (expr, args, complain, in_decl); > if (targs) > targs =3D tsubst_template_args (targs, args, complain, in_decl); >=20=20 > - return lookup_template_function (fn, targs); > + if (variable_template_p (expr)) > + return lookup_and_finish_template_variable (expr, targs, complain); > + else > + return lookup_template_function (expr, targs); > } >=20=20 > case TREE_LIST: > but that just means an ICE elsewhere. Hmm, seems using lookup_template_variable instead of lookup_and_finish_template_variable works.=