https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109095
Bug ID: 109095 Summary: ICE when specializing a template with an auto nontype template template parameter Product: gcc Version: 12.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: n.morales.0 at proton dot me Target Milestone: --- This ICE is present in gcc 12.1/2 and in trunk: template< typename T > struct bar {}; template< int X > struct baz {}; template< auto N, template< auto N2 > typename TT > struct foo; template< typename T, bar< T > B, template< T N2 > typename TT > struct foo< B, TT > {}; foo< bar< int >{}, baz > x; This code ICE's with the following message when compiled with -std=c++20 -Werror -Wall -Wextra <source>:13:19: internal compiler error: in tsubst, at cp/pt.cc:15867 13 | struct foo< B, TT > | ^ 0x1bb069e internal_error(char const*, ...) ???:0 0x6ff396 fancy_abort(char const*, int, char const*) ???:0 0x884007 lookup_template_class(tree_node*, tree_node*, tree_node*, tree_node*, int, int) ???:0 0x8aa461 finish_template_type(tree_node*, tree_node*, int) ???:0 0x861eaa c_parse_file() ???:0 0x93e4e5 c_common_parse_file() ???:0 I found a workaround to the ICE by making N2 "auto" instead of "T". Also, this code compiles fine on clang 15. Here is a godbolt link: https://godbolt.org/z/vxxeG36Gz