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

2023-01-15


1218. What is the “currently-handled exception” in a multi-threaded program?

Section: 14.4  [except.handle]     Status: C++11     Submitter: CA     Date: 2010-11-12

[Voted into the WP at the March, 2011 meeting.]

N3092 comment CA 5

14.4 [except.handle] paragraph 8 defines the “currently handled exception” as

The exception with the most recently activated handler that is still active

This definition ignores the possibility that an exception might be thrown and caught in another thread during the execution of a handler. Since throw; rethrows the “currently handled exception,” one might conclude that it would be the other thread's exception that would be rethrown instead of the one that activated that handler.

Proposed resolution (January, 2011):

  1. Change Clause 14 [except] paragraph 1 as follows:

  2. Exception handling provides a way of transferring control and information from a point in the execution of a program thread to an exception handler associated with a point previously passed by the execution...
  3. Change 14.2 [except.throw] paragraph 4 as follows:

  4. ...The implementation may then deallocate the memory for the exception object; any such deallocation is done in an unspecified way. [Note: An exception thrown by a throw-expression does not propagate to other threads unless caught, stored, and rethrown using appropriate library functions; see 17.9.7 [propagation] and 33.10 [futures]. —end note]
  5. Change 14.4 [except.handle] paragraph 6 as follows:

  6. If no match is found among the handlers for a try block, the search for a matching handler continues in a dynamically surrounding try block of the same thread.