This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 114a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-04-18


829. At what point is std::unexpected called?

Section: 14.5  [except.spec]     Status: NAD     Submitter: UK     Date: 3 March, 2009

N2800 comment UK 135

It is unclear whether std::unexpected is called before or after the destruction of function arguments, partially-constructed bases and members (when called from a constructor or destructor), etc.

Rationale (October, 2009):

The point at which std::unexpected is called is specified in _N4606_.15.5.2 [except.unexpected] paragraph 1:

If a function with an exception-specification throws an exception that is not listed in the exception-specification, the function std::unexpected() is called (_N4606_.D.6 [exception.unexpected]) immediately after completing the stack unwinding for the former function.

That is, it will be called after any local automatic objects and temporaries are destroyed and before any other objects, such as function arguments, are destroyed. (See 7.6.1.3 [expr.call] paragraph 4: “The initialization and destruction of each parameter occurs within the context of the calling function.”)