When an exception occurs, all the local objects created during execution are destroyed in reverse order; this mechanism is called stack unwinding. During stack unwinding, destructors for all these local objects are called, and then the catch block is executed.