http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49118
Summary: Endless operator-> chain causes infinite loop Product: gcc Version: 4.5.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: pot...@mac.com When the "drill-down" behavior is used to chain operator-> calls, a cycle in the chain causes an immediate error message, but an endless acyclic chain causes the compiler to hang, very slowly consuming memory. Minimal case: template< int n > struct a { a< n+1 > operator->() { return a< n+1 >(); } }; int main() { a<0>()->x; } Suggested fix: If operator-> returns a template specialization, consider its instantiation to be nested. This existing error message and limit-mechanism would be appropriate: error: template instantiation depth exceeds maximum of 500 (use -ftemplate-depth-NN to increase the maximum) instantiating ‘struct a<500>’