https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81866
--- Comment #8 from Sokolov Viacheslav <soko.slav at yandex dot ru> --- looks like the following is the same bug: https://godbolt.org/z/1vTqs3 template <typename = void> struct A { template <typename = void> struct B { }; }; A<>::B b; results in (on trunk) <source>: In substitution of 'template<class> B()-> A<>::B< <template-parameter-1-1> > [with <template-parameter-1-1> = void]': <source>:10:8: required from here <source>:5:12: internal compiler error: in retrieve_specialization, at cp/pt.c:1248 5 | struct B | ^ 0x1ce8359 internal_error(char const*, ...) ???:0 0x6b702d fancy_abort(char const*, int, char const*) ???:0 0x91364f tsubst(tree_node*, tree_node*, int, tree_node*) ???:0 0x9498ff instantiate_template(tree_node*, tree_node*, int) ???:0 0x9513f6 fn_type_unification(tree_node*, tree_node*, tree_node*, tree_node* const*, unsigned int, tree_node*, unification_kind_t, int, conversion**, bool, bool) ???:0 0x6de832 build_new_function_call(tree_node*, vec<tree_node*, va_gc, vl_embed>**, int) ???:0 0x906642 do_auto_deduction(tree_node*, tree_node*, tree_node*, int, auto_deduction_context, tree_node*, int) ???:0 0x7b05d4 cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int) ???:0 0x8de81d c_parse_file() ???:0 0xa5c452 c_common_parse_file() ???:0 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. Compiler returned: 1