What happens when we throw from a destructor? I know that it causes terminate() to be called, and memory is indeed freed and the destructor is called, but, is this before or after throw is called from foo? Perhaps the issue here is that throw is used while the stack is unwinding that is the problem.
What happens when we throw from a destructor? I know that it causes terminate()
Share
This is what is happening:
foo()is calledaof typeAis created on the stackais called, which throws another exceptionstd::terminateis called — which is nothing but abandoning the exception handling mechanism:From C++0x draft: