https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87847
--- Comment #5 from Martin Liška <marxin at gcc dot gnu.org> --- (In reply to Marek Polacek from comment #4) > Or maybe just > > @@ -1879,6 +1888,9 @@ iterative_hash_template_arg (tree arg, hashval_t val) > return val; > } > > + case TEMPLATE_TEMPLATE_PARM: > + return val; > + > default: > break; > } Thank you Marek for working on that. If I apply both my and your patches I've got: $ cat ba.ii template < typename > struct A; template < typename > class B { public: typedef int value_type; typedef int pointer; typedef int reference; typedef int const_reference; typedef long size_type; typedef long difference_type; typedef int iterator; }; template < typename _Tp > class _Bitmap_counter { typedef B< A< _Tp > > _BPVector; typedef typename _BPVector::size_type _Index_type; typedef _Tp pointer; public: _Bitmap_counter(_BPVector); }; B< long > a; template < typename > class bitmap_allocator { typedef long size_type; typedef long difference_type; typedef int pointer; struct _Alloc_block; typedef A< _Alloc_block * > _Block_pair; typedef B< _Block_pair > _BPVector; static _BPVector b; static _Bitmap_counter< _Alloc_block * > d; }; template < typename _Tp > _Bitmap_counter< typename bitmap_allocator< _Tp >::_Alloc_block * > bitmap_allocator< _Tp >::d(b); template class B< A< bitmap_allocator< wchar_t >::_Alloc_block * > >; template class bitmap_allocator< char >; $ /home/marxin/Programming/gcc2/objdir/./gcc/xgcc -B/home/marxin/Programming/gcc2/objdir/./gcc ba.ii ba.ii: In instantiation of ‘_Bitmap_counter<bitmap_allocator<char>::_Alloc_block*> bitmap_allocator<char>::d’: ba.ii:8:17: required from here ba.ii:6:127: internal compiler error: in instantiate_decl, at cp/pt.c:24494 6 | template < typename _Tp > _Bitmap_counter< typename bitmap_allocator< _Tp >::_Alloc_block * > bitmap_allocator< _Tp >::d(b); | ^ 0x9a3dea instantiate_decl(tree_node*, bool, bool) ../../gcc/cp/pt.c:24493 0x8e1cf3 mark_used(tree_node*, int) ../../gcc/cp/decl2.c:5561 0x9aca07 tsubst_copy ../../gcc/cp/pt.c:15714 0x997e37 tsubst_copy ../../gcc/cp/pt.c:15534 0x997e37 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool) ../../gcc/cp/pt.c:19483 0x999f64 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool) ../../gcc/cp/pt.c:19606 0x99ae44 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool) ../../gcc/cp/pt.c:19244 0x9a7348 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool) ../../gcc/cp/pt.c:18248 0x9a7348 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) ../../gcc/cp/pt.c:17924 0x9aaae4 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) ../../gcc/cp/pt.c:17015 0x9aaae4 tsubst_init ../../gcc/cp/pt.c:15493 0x9a27d1 regenerate_decl_from_template ../../gcc/cp/pt.c:24163 0x9a27d1 instantiate_decl(tree_node*, bool, bool) ../../gcc/cp/pt.c:24707 0x9bc031 do_type_instantiation(tree_node*, tree_node*, int) ../../gcc/cp/pt.c:24024 0x975f37 cp_parser_explicit_instantiation ../../gcc/cp/parser.c:17206 0x9785b1 cp_parser_declaration ../../gcc/cp/parser.c:13190 0x978c9f cp_parser_translation_unit ../../gcc/cp/parser.c:4701 0x978c9f c_parse_file() ../../gcc/cp/parser.c:41181 0xa82ce0 c_common_parse_file() ../../gcc/c-family/c-opts.c:1156 $ g++-8 ba.ii -c [OK]