From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 8BF25395C438; Fri, 13 May 2022 13:40:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8BF25395C438 From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/102479] segfault when deducing class template arguments for tuple with libc++-14 Date: Fri, 13 May 2022 13:40:11 +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.1.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: RESOLVED X-Bugzilla-Resolution: FIXED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: ppalka at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.0 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, 13 May 2022 13:40:11 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102479 --- Comment #9 from CVS Commits --- The releases/gcc-11 branch has been updated by Patrick Palka : https://gcc.gnu.org/g:f705d0f2d03cc4d9f890832798b3352553f2262f commit r11-9992-gf705d0f2d03cc4d9f890832798b3352553f2262f Author: Patrick Palka Date: Mon Sep 27 16:01:10 2021 -0400 c++: deduction guides and ttp rewriting [PR102479] The problem here is ultimately that rewrite_tparm_list when rewriting a TEMPLATE_TEMPLATE_PARM introduces a tree cycle in the rewritten ttp that structural_comptypes can't cope with. In particular the DECL_TEMPLATE_PARMS of a ttp's TEMPLATE_DECL normally captures an empty parameter list at its own level (and so the TEMPLATE_DECL doesn't appear in its own DECL_TEMPLATE_PARMS), but rewrite_tparm_list ends up giving it a complete parameter list. In the new testcase below, this causes infinite recursion from structural_comptypes when comparing Tmpl with Tmpl (where both 'Tmpl's are rewritten ttps). This patch fixes this by making rewrite_template_parm give a rewritten template template parm an empty parameter list at its own level, thereby avoiding the tree cycle. Testing the alias CTAD case revealed that we're not setting current_template_parms in alias_ctad_tweaks, which this patch also fixes. PR c++/102479 gcc/cp/ChangeLog: * pt.c (rewrite_template_parm): Handle single-level tsubst_args. Avoid a tree cycle when assigning the DECL_TEMPLATE_PARMS for a rewritten ttp. (alias_ctad_tweaks): Set current_template_parms accordingly. gcc/testsuite/ChangeLog: * g++.dg/cpp1z/class-deduction12.C: Also test alias CTAD in the same way. * g++.dg/cpp1z/class-deduction99.C: New test. (cherry picked from commit 51018dd1395c72b3681ae5f84eceb94320472922)=