你能举一个C++中堆栈溢出的例子吗?

2022-01-23 00:00:00 debugging stack-overflow visual-c++ g++ c++

你能举一个 C++ 中堆栈溢出的例子吗?除了递归情况:

Can you give an example of stack overflow in C++? Other than the recursive case:

void foo() { foo(); }

推荐答案

不涉及无限递归的典型情况是在堆栈上声明一个太大的自动变量.例如:

The typical case that does not involve infinite recursion is declaring an automatic variable on the stack that is too large. For example:

int foo()
{
    int array[1000000];

}

相关文章