http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55581
Bug #: 55581 Summary: Too-eager instantiation Classification: Unclassified Product: gcc Version: 4.7.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: d...@boostpro.com IMO this program should compile with -ftemplate-depth=1, as it does on Clang. [Sorry for the inline code; technical difficulties prevent me from adding an attachment before I reboot my machine] template <long N> struct mooch { struct arrow { mooch<N-1> operator->(); }; arrow operator->(); }; template <> struct mooch<0> { int x; mooch<0>* operator->(); }; mooch<10000> a; // compiles with -ftemplate-depth 1 decltype(a.operator->()) y; // compiles with -ftemplate-depth 1 decltype(a->x) z; // requires -ftemplate-depth=20000 on g++ but not on clang++