Reputation: 131
I'm not sure how to approach it. The question was given after a lecture about Exceptions so I assume it has something to do with it.
Upvotes: 1
Views: 440
Reputation: 1796
When a scope is exited, stack unwinding starts, which means the compiler inserts calls to destructors of automatic variables, as explained in this answer.
For this process to be prevented, you would need a sudden exiting of the process, which could be loss of power, force quitting the process through the command line, etc.
Upvotes: 1
Reputation: 1
Default signal handlers, or calls to abort()
and exit()
could prevent stack unvinding.
And there's many more situations, like pointed out in mah's comment.
Especially any mechanism bypassing the c++ exception model will do so. Even threads have a model to do proper stack unwinding, with having them propagated to their parents (if they weren't detached).
Upvotes: 1