How to detect possible / potential stack overflow problems in a c / c++ program?
Is there a standard way to see how much stack space your app has and what the highest watermark for stack usage is during a run? Also in the dreaded case of actual overflow what happens? Does it crash, trigger an exception or signal? Is there a standard or is it different on all systems and compilers? I'm looking specifically for Windows, Linux and Macintosh. On Windows a stack overflow exception will be generated. The following windows code illustrates this: #include <stdio.h> #include <windows.h> void StackOverFlow() { CONTEXT context; // we are interested control registers context