From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 82BBF385B53B; Fri, 12 May 2023 15:07:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 82BBF385B53B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1683904072; bh=4Zo147Y5YcGwmr6ciEBfXcrHc7kvA0J6woJEw0Wsf6c=; h=From:To:Subject:Date:In-Reply-To:References:From; b=mBUB3WqPTT+6BXxcTdNt7lRqOWTFcHuopaMcKhIkWT78llCDpf9R8I7vG46rW1HRz B1FE5bCfYa4TUnG2KousK2rgjZx1aojj9O3i8HPd27k29YP7I3FsZPRIDBOY4bIdae Xm7iMiszEldyUPn2gNVWCS42mYAJboGEkhn41uXE= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/109651] [13 Regression] ICE in lookup_template_class since r14-11-g2245459c85a3f4 Date: Fri, 12 May 2023 15:07: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: 13.0 X-Bugzilla-Keywords: ice-on-valid-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: P2 X-Bugzilla-Assigned-To: ppalka at gcc dot gnu.org X-Bugzilla-Target-Milestone: 13.2 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=3D109651 --- Comment #9 from CVS Commits --- The releases/gcc-13 branch has been updated by Patrick Palka : https://gcc.gnu.org/g:986e38bcb0368a884fb4ea16159dd852406af078 commit r13-7322-g986e38bcb0368a884fb4ea16159dd852406af078 Author: Patrick Palka Date: Sun May 7 11:54:21 2023 -0400 c++: bound ttp in lambda function type [PR109651] After r14-11-g2245459c85a3f4 we now coerce the template arguments of a bound ttp again after level-lowering it. Notably a level-lowered ttp doesn't have DECL_CONTEXT set, so during this coercion we fall back to using current_template_parms to obtain the relevant set of in-scope parameters. But it turns out current_template_parms isn't properly set when substituting the function type of a generic lambda, and so if the type contains bound ttps that need to be lowered we'll crash during their attempted coercion. Specifically in the first testcase below, current_template_parms during the lambda type substitution (with T=3Din= t) is "1 U" instead of the expected "2 TT, 1 U", and we crash when level lowering TT. Ultimately the problem is that tsubst_lambda_expr does things in the wrong order: we ought to substitute (and install) the in-scope template parameters _before_ substituting anything that may use those template parameters (such as the function type of a generic lambda). This patch corrects this substitution order. PR c++/109651 gcc/cp/ChangeLog: * pt.cc (coerce_template_args_for_ttp): Mention we can hit the current_template_parms fallback when level-lowering a bound ttp. (tsubst_template_decl): Add lambda_tparms parameter. Prefer to use lambda_tparms instead of substituting DECL_TEMPLATE_PARMS. (tsubst_decl) : Pass NULL_TREE as lambda_tp= arms to tsubst_template_decl. (tsubst_lambda_expr): For a generic lambda, substitute DECL_TEMPLATE_PARMS and set current_template_parms to it before substituting the function type. Pass the substituted DECL_TEMPLATE_PARMS as lambda_tparms to tsubst_template_decl. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/lambda-generic-ttp1.C: New test. * g++.dg/cpp2a/lambda-generic-ttp2.C: New test. (cherry picked from commit 7bfb1550ccea7c426d50244e980f01f30db8ba0c)=