E2418 Maximum instantiation depth exceeded; check for recursion (C++)

From RAD Studio
Jump to: navigation, search

Go Up to Compiler Errors And Warnings (C++) Index

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
}