Summary: | [4.6/4.7/4.8 Regression] internal compiler error: in tsubst_copy, at cp/pt.c:12131 | ||
---|---|---|---|
Product: | gcc | Reporter: | DS <dsagald8> |
Component: | c++ | Assignee: | Jason Merrill <jason> |
Status: | VERIFIED FIXED | ||
Severity: | normal | CC: | jakub, jason |
Priority: | P2 | ||
Version: | 4.7.2 | ||
Target Milestone: | 4.6.4 | ||
Host: | Target: | ||
Build: | Known to work: | ||
Known to fail: | Last reconfirmed: | 2013-02-07 00:00:00 | |
Attachments: | Test case |
Description
DS
2013-02-07 22:28:25 UTC
Confirmed. 4.5.4 works for me. Author: jason Date: Sat Feb 9 20:39:13 2013 New Revision: 195922 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=195922 Log: PR c++/56247 * pt.c (eq_specializations): Set comparing_specializations. * tree.c (cp_tree_equal): Check it. * cp-tree.h: Declare it. Added: trunk/gcc/testsuite/g++.dg/template/ptrmem23.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/cp-tree.h trunk/gcc/cp/pt.c trunk/gcc/cp/tree.c Author: jason Date: Sat Feb 9 20:47:24 2013 New Revision: 195923 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=195923 Log: PR c++/56247 * pt.c (eq_specializations): Set comparing_specializations. * tree.c (cp_tree_equal): Check it. * cp-tree.h: Declare it. Added: branches/gcc-4_7-branch/gcc/testsuite/g++.dg/template/ptrmem23.C Modified: branches/gcc-4_7-branch/gcc/cp/ChangeLog branches/gcc-4_7-branch/gcc/cp/cp-tree.h branches/gcc-4_7-branch/gcc/cp/pt.c branches/gcc-4_7-branch/gcc/cp/tree.c Author: jason Date: Sat Feb 9 20:53:59 2013 New Revision: 195924 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=195924 Log: PR c++/56247 * pt.c (eq_specializations): Set comparing_specializations. * tree.c (cp_tree_equal): Check it. * cp-tree.h: Declare it. Added: branches/gcc-4_6-branch/gcc/testsuite/g++.dg/template/ptrmem23.C Modified: branches/gcc-4_6-branch/gcc/cp/ChangeLog branches/gcc-4_6-branch/gcc/cp/cp-tree.h branches/gcc-4_6-branch/gcc/cp/pt.c branches/gcc-4_6-branch/gcc/cp/tree.c Fixed. Awesome quick work. Very impressive -- thank you! The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>: https://gcc.gnu.org/g:f83adb68ed9cef1fbd4c16447eb4e89676df9f62 commit r10-7787-gf83adb68ed9cef1fbd4c16447eb4e89676df9f62 Author: Patrick Palka <ppalka@redhat.com> Date: Sat Apr 18 06:22:21 2020 -0400 c++: spec_hasher::equal and PARM_DECLs [PR94632] In the testcase below, during specialization of c<int>::d, we build two identical specializations of the parameter type b<decltype(e)::k> -- one when substituting into c<int>::d's TYPE_ARG_TYPES and another when substituting into c<int>::d's DECL_ARGUMENTS. We don't reuse the first specialization the second time around as a consequence of the fix for PR c++/56247 which made PARM_DECLs always compare different from one another during spec_hasher::equal. As a result, when looking up existing specializations of 'b', spec_hasher::equal considers the template argument decltype(e')::k to be different from decltype(e'')::k, where e' and e'' are the result of two calls to tsubst_copy on the PARM_DECL e. Since the two specializations are considered different due to the mentioned fix, their TYPE_CANONICAL points to themselves even though they are otherwise identical types, and this triggers an ICE in maybe_rebuild_function_decl_type when comparing the TYPE_ARG_TYPES of c<int>::d to its DECL_ARGUMENTS. This patch fixes this issue at the spec_hasher::equal level by ignoring the 'comparing_specializations' flag in cp_tree_equal whenever the DECL_CONTEXTs of the two parameters are identical. This seems to be a sufficient condition to be able to correctly compare PARM_DECLs structurally. (This also subsumes the CONSTRAINT_VAR_P check since constraint variables all have empty, and therefore identical, DECL_CONTEXTs.) gcc/cp/ChangeLog: PR c++/94632 * tree.c (cp_tree_equal) <case PARM_DECL>: Ignore comparing_specializations if the parameters' contexts are identical. gcc/testsuite/ChangeLog: PR c++/94632 * g++.dg/template/canon-type-14.C: New test. |