This question comes from SetJmp/LongJmp: Why is this throwing a segfault?
When I use debug mode run the code it did crash as expect. But if I use release it will output like this:
1 setjmping a_buf
2 calling b // loop start
3 entering b_helper
4 longjmping to a_buf
5 longjmping to b_buf
6 returning from b_helper // loop
2 calling b
3 entering b_helper
4 longjmping to a_buf
5 longjmping to b_buf
6 returning from b_helper
...
As my understanding, longjmp can be considered as return so the stack memory of b_helper will be erased and accessing become illegal. that make the program crash become reasonable.
But why it gives different behaviour in release? Looks like return behave as longjmp.
So the result in release shall be the right and my understanding is wrong.
Mingw: 5.3