Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does stack overflow throw no error in Visual C++?

In Microsoft Visual C++ 2010 I created a program which delibrately causes a stack overflow. When I run the program using "start debugging" an error is thrown when stack overflow occurs. When I run it with "start without debugging" no error is thrown and the program just terminates silently as if it had successfully completed. Could someone explain to me what's going on? Also do any other compilers not throw errors on stack overflow?

(I thought this would be the right place to ask a question about stack overflow.)

like image 563
qaz Avatar asked Nov 29 '22 05:11

qaz


2 Answers

C++ won't hold your hand as a managed enviroment does. Having a stack overflow means undefined behaviour.

like image 80
Tamás Szelei Avatar answered Dec 01 '22 18:12

Tamás Szelei


A stack overflow is undefined behaviour. The compiler is well within it's rights to ignore it or cause any event to happen.

like image 26
Puppy Avatar answered Dec 01 '22 20:12

Puppy