I'm pondering a question on Brainbench. I actually realised that I could answer my question easily by compiling the code, but it's an interesting question nonetheless, so I'll ask the question anyway and answer it myself shortly.
Take a look at this snippet:
The question considers what happens when we throw
from a destructor (which causes terminate()
to be called). It's become clear to me by asking the question that the 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... Actually this is slightly confusing.