RAD Studio
ContentsIndex
PreviousUpNext
E2418: Maximum instantiation depth exceeded; check for recursion (C++)

The compiler only supports 256 levels of instantiation before it will trigger this error. The main problem is in controlling stack depth, because the parser uses recursive functions to manage type instantiation. Here is an example that would produce such an error:

template<int T>
class foo {
public:
static const int x = foo<T – 1>::x;
};
template<int T>
class foo<1> {
public:
static const int x = 1;
};
int main() {
int y = foo<100000>::x;// error: instantiation depth exceeded
}
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!