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


1503. Exceptions during copy to exception object

Section: 14.2  [except.throw]     Status: CD3     Submitter: Daniel Krügler     Date: 2012-05-11

[Moved to DR at the April, 2013 meeting.]

According to 14.2 [except.throw] paragraph 7,

If the exception handling mechanism, after completing evaluation of the expression to be thrown but before the exception is caught, calls a function that exits via an exception, std::terminate is called (14.6.2 [except.terminate]).

This wording was overlooked in the resolution for issue 475 and should be changed, along with the following example, to indicate that std::terminate will be called for an uncaught exception only after initialization of the exception object is complete.

Proposed resolution (August, 2012):

Change 14.2 [except.throw] paragraph 7 as follows:

If the exception handling mechanism, after completing evaluation of the expression to be thrown the initialization of the exception object but before the exception is caught activation of a handler for the exception, calls a function that exits via an exception, std::terminate is called (14.6.2 [except.terminate]). [Example:

  struct C {
    C() { }
    C(const C&) { throw 0; }
      if (std::uncaught_exception()) {
        throw 0;    // throw during copy to handler's exception-declaration object (14.4 [except.handle])
      }
    }
  };

  int main() {
    try {
      throw C();   // calls std::terminate() if construction of the handler's
                   // exception-declaration object is not elided (11.4.5.3 [class.copy.ctor])
    } catch(C) { }
  }

end example]