https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123186
--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> --- I've already bootstrapped 2025-12-18 Jakub Jelinek <[email protected]> PR c++/123186 * parser.cc (cp_parser_template_id): Use TYPE_IDENTIFIER instead of TYPE_NAME in second build_typename_type argument. * g++.dg/template/crash133.C: New test. --- gcc/cp/parser.cc.jj 2025-12-17 15:21:21.045719368 +0100 +++ gcc/cp/parser.cc 2025-12-18 11:11:56.074952675 +0100 @@ -20435,7 +20435,7 @@ cp_parser_template_id (cp_parser *parser fullname, arguments); TREE_TYPE (templ) = build_typename_type (TYPE_CONTEXT (TREE_TYPE (templ)), - TYPE_NAME (TREE_TYPE (templ)), + TYPE_IDENTIFIER (TREE_TYPE (templ)), fullname, get_typename_tag (TREE_TYPE (templ))); template_id = templ; --- gcc/testsuite/g++.dg/template/crash133.C.jj 2025-12-18 13:22:56.797502427 +0100 +++ gcc/testsuite/g++.dg/template/crash133.C 2025-12-18 13:22:49.365630906 +0100 @@ -0,0 +1,6 @@ +// PR c++/123186 + +template <class T> +struct A : T { + typename A <T>::template B <42> C; +}; and am regtesting it right now, but if you want to do something different, go ahead.
