https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103667
Bug ID: 103667 Summary: [12 Regression] Accepting invalid explicitly specialized template with incorrectly ordered template parameter lists Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: matthewjbarichello at gmail dot com Target Milestone: --- The following invalid code compiles without an error in GCC 12: template<typename... Args> struct A { template<auto N> struct B {}; }; template<> template<typename... Args> struct A<Args...>::B<sizeof...(Args)> {}; In versions before 12, compilation yields the following diagnostic: <source>:9:22: error: template argument 'sizeof... (Args)' involves template parameter(s) 9 | struct A<Args...>::B<sizeof...(Args)> {}; | ^~~~~~~~~~~~~~~ Adding the following code to the example causes a parser ICE: int main() { A<>::B<0> b{}; } ICE trace: <source>: In function 'int main()': <source>:9:20: internal compiler error: in retrieve_specialization, at cp/pt.c:1260 9 | struct A<Args...>::B<sizeof...(Args)> {}; | ^~~~~~~~~~~~~~~~~~ 0x2100639 internal_error(char const*, ...) ???:0 0x7e96eb fancy_abort(char const*, int, char const*) ???:0 0xa5db37 tsubst(tree_node*, tree_node*, int, tree_node*) ???:0 0xa942e9 most_specialized_partial_spec(tree_node*, int) ???:0 0xaa14f4 instantiate_class_template(tree_node*) ???:0 0x8bd4e7 start_decl_1(tree_node*, bool) ???:0 0x8e49bf start_decl(cp_declarator const*, cp_decl_specifier_seq*, int, tree_node*, tree_node*, tree_node**) ???:0 0xa29b8d c_parse_file() ???:0 0xbb6bb2 c_common_parse_file() ???:0