[except.ctor] (original) (raw)

Each object with automatic storage duration is destroyed if it has been constructed, but not yet destroyed, since the try block was entered.

If an exception is thrown during the destruction of temporaries or local variables for a return statement ([stmt.return]), the destructor for the returned object (if any) is also invoked.

The objects are destroyed in the reverse order of the completion of their construction.

[Example 1: struct A { };struct Y { ~Y() noexcept(false) { throw 0; } }; A f() { try { A a; Y y; A b;return {}; } catch (...) { } return {}; }

At #1, the returned object of type A is constructed.

Then, the local variable b is destroyed ([stmt.jump]).

Next, the local variable y is destroyed, causing stack unwinding, resulting in the destruction of the returned object, followed by the destruction of the local variable a.

Finally, the returned object is constructed again at #2.

— _end example_]