I took a look at the draft C++0x standard, and as far as I can tell there is nothing about stack overflow in there. Searching for "stack overflow" yields no results, and searching for "stack" I've only gotten references to stack unwinding and std::stack. Does that mean that there cannot be a conforming implementation of the C++ standard, since there is no mechanism allowed for handling the error when memory is exhausted by a local object such as a huge local array?
The answers to this question indicate that at least the C standard does not mention stack overflow.
To make the question concrete, consider this program
// Program A
int identity(int a) {
if (a == 0)
return 0;
char hugeArray[1024 * 1024 * 1024]; // 1 GB
return identity(a - 1) + 1;
}
int main() {
return f(1024 * 1024 * 1024);
}
and this program
// program B
int main() {
return 1024 * 1024 * 1024;
}
I think the C++ standard does not allow any C++ implementation to do something observably different on these two programs. In reality program A won't run on any modern machine as it is allocating an exabyte of memory on the stack (imagine the function actually used the huge array so the compiler can't silently remove it to no ill effect). Does the C++ standard allow program A to fail?
Edit: The question is not whether the standard should define what happens on stack overflow, the question is what it says, if anything.