From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 292C33858414; Fri, 19 May 2023 13:40:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 292C33858414 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1684503641; bh=IFL1bwxX/uYVIfG9AmjIMzuVRe7kFCNATliaZxoWogE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=SV9rj32s8y7boimCpOPtgQUdFDHM4Tj1dVMrKjVa2ug8ThqGPv59Bw+YK0p+ZPgeu pfv0GF4uHZX55gSDhcWbVZkIZqe2yIQCXbkxo1WxB7vAuaLJqDUMCjfiHnbiYvjPT/ c6DXiLQg+3e+JsheXwLS88smajRR62TCmDGloJGg= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/97340] Spurious rejection of member variable template of reference type Date: Fri, 19 May 2023 13:40:40 +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: rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D97340 --- Comment #4 from CVS Commits --- The master branch has been updated by Patrick Palka : https://gcc.gnu.org/g:ef8926d23a458560b8e9be1a76cf29ddcb87ec2a commit r14-997-gef8926d23a458560b8e9be1a76cf29ddcb87ec2a Author: Patrick Palka Date: Fri May 19 09:40:16 2023 -0400 c++: scoped variable template-id of reference type [PR97340] lookup_and_finish_template_variable calls convert_from_reference, which means for a variable template-id of reference type the function wraps the corresponding VAR_DECL in an INDIRECT_REF. But the downstream logic of two callers, tsubst_qualified_id and finish_class_member_access_expr, expect a DECL_P result and this unexpected INDIRECT_REF leads to an ICE resolving such a (dependently scoped) template-id as in the first testc= ase. (Note these two callers eventually call convert_from_reference on the result anyway, so calling it earlier seems redundant in this case.) This patch fixes this by pulling out the convert_from_reference call from lookup_and_finish_template_variable and into the callers that actually need it, which turns out to only be tsubst_copy_and_build (if we got rid of the call there we'd mishandle the second testcase). PR c++/97340 gcc/cp/ChangeLog: * pt.cc (lookup_and_finish_template_variable): Don't call convert_from_reference. (tsubst_copy_and_build) : Call convert_from_reference on the result of lookup_and_finish_template_variable. gcc/testsuite/ChangeLog: * g++.dg/cpp1y/var-templ80.C: New test. * g++.dg/cpp1y/var-templ81.C: New test.=