I always thought that the stack was supposed to be unwound when the catch block is finished, after an exception. The long experience I've had with exceptions certainly supports this. A recent experience says otherwise. The code I used can be abstracted this way:
I had a segfault which Valgrind says was caused by that global pointer being set to null. However, as the name suggests, that pointer should only have been set to null after the_class was destroyed, and the_class should have only been destroyed once the catch block was finished... or so I was told. Is that wrong, or should I be looking elsewhere in my code, because the_class's destructor can never precede code in the catch block?Code:try { A_class_that_sets_a_global_pointer_to_null_in_its_destructor the_class; the_class.some_method_that_throws_an_exception(); } catch(myexception &ex) { code_that_uses_above_mentioned_global_pointer(); }//point at which I expected the stack to be unwound
What does the standard really say? I'm using GNU here, but that shouldn't be germane to the standard.
Edit: and you know what, maybe I'm not even using the term "unwind" correctly. I'm going back to reresearch the issue, and I'm starting to wonder if I was wrong to equate "stack unwinding" with "deallocation of objects on the stack"