Without using recursion how can a stack overflow exception be thrown?

前端 未结 10 2073
自闭症患者
自闭症患者 2021-01-18 04:19

Without using recursion how can a stack overflow exception be thrown?

10条回答
  •  南方客
    南方客 (楼主)
    2021-01-18 04:56

    int main()
    {
      //something on the stack
      int foo = 0;
      for (
        //pointer to an address on the stack
        int* p = &foo;
        //forever
        ;
        //ever lower on the stack (assuming that the stack grows downwards)
        --p)
      {
        //write to the stack
        *p = 42;
      }
    }
    

提交回复
热议问题