Can you give an example of stack overflow in C++?

后端 未结 12 1567
不知归路
不知归路 2020-12-31 18:52

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

void foo() { foo(); }
12条回答
  •  独厮守ぢ
    2020-12-31 19:49

    This example shows uncontrolled recursion. Eventually, the stack spaced allocated to this process will be completely overwritten by instances of bar and ret...

    int foo( int bar )
    {
        int ret = foo( 42 );
        return ret;
    }
    

提交回复
热议问题