https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70468
--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> --- It is the expand_member_init's current_template_parms check that matters here, with - if (current_template_parms - || same_type_p (basetype, current_class_type)) - return basetype; + if (/* current_template_parms + || */same_type_p (basetype, current_class_type)) + return basetype; both testcases from this PR are properly rejected and no ICEs. That breaks other stuff though, like: /usr/src/gcc/obj/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/allocator.h:134:9: error: type '__gnu_cxx::new_allocator<_Tp>' is not a direct base of 'std::allocator< <template-parameter-1-1> >' /usr/src/gcc/obj/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/basic_string.h:146:4: error: type 'typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_CharT>::other' is not a direct base of 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_Alloc_hider' /usr/src/gcc/obj/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/basic_string.h:149:4: error: type 'typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_CharT>::other' is not a direct base of 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_Alloc_hider'