http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54728
--- Comment #2 from Dmitry G. Dyachenko <dimhen at gmail dot com> 2012-09-27 12:27:33 UTC --- for reduced test case: $ cp fun1.ii fun2.ii $ g++... $ cat fun1.ii class G; template < typename, typename = G > class A; class B { }; class G:B { }; template < typename _CharT, typename _Alloc > class A { struct C { static C & _S_empty_rep (); _CharT *_M_refdata (); }; struct H:_Alloc { H (_CharT *, _Alloc):_Alloc () { } }; H _M_dataplus; C & _S_empty_rep () { return C::_S_empty_rep (); } public: A ():_M_dataplus (_S_empty_rep ()._M_refdata (), _Alloc ()) { } }; extern template class A < char >; class D { }; class F { }; template < typename _CharT > class I:D { typedef _CharT char_type; typedef A < char_type > __string_type; __string_type _M_string; }; template < typename _CharT > class J:F { typedef I < _CharT > __stringbuf_type; __stringbuf_type _M_stringbuf; }; J < char >a;