https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99697
Bug ID: 99697 Summary: ICE for class template partial specialization over non-template (structural class template) parameter of deduced class type Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: davveston at gmail dot com Target Milestone: --- The following program: // ----------------------------------- // prog.cc template<int N> struct S {}; template<S s> struct U {}; template<typename> struct V; template<S s> struct V<U<s<0>> {}; // #1: ICE int main() {} // ----------------------------------- compiled with gcc HEAD 11.0.1 20210320 (experimental) and the following command g++ prog.cc -Wall -Wextra -std=gnu++2b results in the following ICE (segfault) at #1: // ----------------------------------- prog.cc:5:28: internal compiler error: Segmentation fault 5 | template<S s> struct V<U<s<0>> {}; // ICE | ^ 0xca91ff crash_signal ../../source/gcc/toplev.c:327 0x63a207 resolve_args(vec<tree_node*, va_gc, vl_embed>*, int) ../../source/gcc/cp/call.c:4548 0x78a764 do_class_deduction ../../source/gcc/cp/pt.c:29332 0x78a764 do_auto_deduction(tree_node*, tree_node*, tree_node*, int, auto_deduction_context, tree_node*, int) ../../source/gcc/cp/pt.c:29509 0x798c37 convert_template_argument ../../source/gcc/cp/pt.c:8491 0x79a19b convert_template_argument ../../source/gcc/cp/pt.c:8264 0x79a19b coerce_template_parms ../../source/gcc/cp/pt.c:8995 0x79b411 lookup_template_class_1 ../../source/gcc/cp/pt.c:9833 0x79c3ec lookup_template_class(tree_node*, tree_node*, tree_node*, tree_node*, int, int) ../../source/gcc/cp/pt.c:10237 0x7c028d finish_template_type(tree_node*, tree_node*, int) ../../source/gcc/cp/semantics.c:3563 0x75f603 cp_parser_template_id ../../source/gcc/cp/parser.c:17458 0x75f86b cp_parser_class_name ../../source/gcc/cp/parser.c:24685 0x75783a cp_parser_qualifying_entity ../../source/gcc/cp/parser.c:7002 0x75783a cp_parser_nested_name_specifier_opt ../../source/gcc/cp/parser.c:6684 0x76c30f cp_parser_simple_type_specifier ../../source/gcc/cp/parser.c:18851 0x74cd8d cp_parser_type_specifier ../../source/gcc/cp/parser.c:18509 0x75d323 cp_parser_type_specifier_seq ../../source/gcc/cp/parser.c:23360 0x75bba4 cp_parser_type_id_1 ../../source/gcc/cp/parser.c:23163 0x75de83 cp_parser_template_type_arg ../../source/gcc/cp/parser.c:23268 0x75dfaf cp_parser_template_argument ../../source/gcc/cp/parser.c:17908 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions. // ----------------------------------- I think the partial specialization at #1 can never be used as the non-type template parameter 's' of deduced class type can never be deduced, such that the correct behaviour should arguably be to reject the program as ill-formed (at #1). Demo: https://wandbox.org/permlink/ufm4B9uIn8dgHYAI