-------- testcase.cpp -------- template < typename > struct A { struct S; A < S > ht; };
struct B : A < B > {}; ------------------------------ without -ftemplate-depth, it instantiates templates up do default depth, giving 760KiB of diagnostics for this simple testcase (for 4.5.0) this is output with -ftemplate-depth-5: $ g++ testcase.cpp -ftemplate-depth-5 testcase.cpp:4: error: template instantiation depth exceeds maximum of 5 (use -ftemplate-depth-NN to increase the maximum) instantiating 'struct A<A<A<A<A<A<B>::S>::S>::S>::S>::S>' testcase.cpp:4: instantiated from 'A<A<A<A<A<B>::S>::S>::S>::S>' testcase.cpp:4: instantiated from 'A<A<A<A<B>::S>::S>::S>' testcase.cpp:4: instantiated from 'A<A<A<B>::S>::S>' testcase.cpp:4: instantiated from 'A<A<B>::S>' testcase.cpp:4: instantiated from 'A<B>' testcase.cpp:7: instantiated from here testcase.cpp:4: error: 'A< <template-parameter-1-1> >::ht' has incomplete type testcase.cpp:2: error: declaration of 'struct A<A<A<A<A<A<B>::S>::S>::S>::S>::S>' ------------------------------ all tested gcc versions behave the same - 2.95, 3.2.3, 3.3.6, 3.4.6, 4.0.4, 4.1.2, 4.2.4, 4.3.4, 4.4.3, 4.5.0 (with the exception that 2.95 bails out at the end, and 3.2.3 and 2.95 need quite long time for even template depth 20) -- Summary: too long diagnostics in some cases of recursive template instantiation Product: gcc Version: 4.5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: zsojka at seznam dot cz http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43113