Alex Rivera | Logout

Does C++ limit recursion depth?

Asked 2010-04-13T13:54:24.743
72

In Python there is a maximum recursion depth. Seems it is because Python is interpreted rather than compiled. Does C++ have the same concept? Or it is connected only with RAM limit?

Edit
Report

2 Answers

33

No, C++ does not have an explicit recursion depth. If the maximum stack size is exceeded (which is 1 MB by default on Windows), your C++ program will overflow your stack and execution will be terminated.

answered 2010-04-13T14:01:38.383
3

I believe the limit is the size of the stack available on the platform. From what I've read, it's 8K 8MB by default on Linux, but modern kernels can adjust the stack size dynamically.

answered 2010-04-13T13:59:56.600

Your Answer