[Bug c++/49118] New: Endless operator-> chain causes infinite loop
potswa at mac dot com
gcc-bugzilla@gcc.gnu.org
Mon May 23 02:56:00 GMT 2011
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: unassigned@gcc.gnu.org
ReportedBy: potswa@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>’
More information about the Gcc-bugs
mailing list