Code example: template<class T> struct Loop { Loop<T*> operator->(); }; Loop<int> i, j = i->something; The compiler doesn't diagnose infinite Loop<> instantiation. Even CLI option ftemplate-depth=n doesn't help.
Both 4.7 and 4.8 exit with a sensible diagnostic: a.cc:2:19: error: template instantiation depth exceeds maximum of 900 (use -ftemplate-depth= to increase the maximum) instantiating ‘Loop<T*> Loop<T>::operator->() [with T = int************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************]’ a.cc:2:19: recursively required from ‘Loop<T*> Loop<T>::operator->() [with T = int]’ a.cc:2:19: required from here a.cc:2:19: error: template instantiation depth exceeds maximum of 900 (use -ftemplate-depth= to increase the maximum) instantiating ‘struct Loop<int*************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************>’ a.cc:2:19: recursively required from ‘Loop<T*> Loop<T>::operator->() [with T = int]’ a.cc:2:19: required from here a.cc:2:19: error: invalid use of incomplete type ‘struct Loop<int*************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************>’ a.cc:1:26: error: declaration of ‘struct Loop<int*************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************>’
Dup of PR49118. *** This bug has been marked as a duplicate of bug 49118 ***