Title
Stack unwinding when no matching handler is found
Status
open
Section
14.4 [except.handle]
Submitter
Hubert Tong

Created on 2026-06-05.00:00:00 last changed yesterday

Messages

Date: 2026-06-08.19:45:49

Possible resolution:

  1. Change in 14.4 [except.handle] paragraph 6 as follows:

    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 fiber. The invocation of the initial function of a fiber is surrounded by an implicit try block.
  2. Change in 14.4 [except.handle] paragraph 8 as follows:

    If no matching handler is found, Otherwise, if the search for a handler exits the function body of the initial function of a fiber, the function std::terminate is invoked; whether. [ Note: Whether or not the stack is unwound before this invocation of std::terminate is implementation-defined (14.6.2 [except.terminate]). -- end note ]
  3. Change in 14.6.2 [except.terminate] paragraph 1 as follows:

    Some errors in a program cannot be recovered from, such as when an exception is not handled or a std::thread object is destroyed while its thread function is still executing. In such cases, the function std::terminate (17.9.5 [exception.terminate]) is invoked.

    [Note 1: These situations are:
    • ...
    • when the exception handling mechanism cannot find a handler for a thrown exception (14.4 [except.handle]), or
    • ...
    • when execution of the initial function of a thread fiber exits via an exception (32.4.3.3 [thread.thread.constr] 14.4 [except.handle]), or
    • ...
    -- end note ]
  4. Change in 14.6.2 [except.terminate] paragraph 2 as follows:

    In the situation where no matching handler is found the search for a handler (14.4 [except.handle]) exits the function body of the initial function of a fiber, it is implementation-defined whether or not the stack is unwound before std::terminate is invoked. In the situation where the search for a handler (14.4 [except.handle]) exits the function body of a function with a non-throwing exception specification (14.5 [except.spec]), it is implementation-defined whether the stack is unwound, unwound partially, or not unwound at all before the function std::terminate is invoked. In all other situations, the stack shall not be unwound before the function std::terminate is invoked. An implementation is not permitted to finish stack unwinding prematurely based on a determination that the unwind process will eventually cause an invocation of the function std::terminate.
Date: 2026-06-05.00:00:00

(From submission #915.)

If stack unwinding does occur in the situation where no matching handler is found, 14.3 [except.ctor] paragraph 2 is ill-defined for lack of a try block.

History
Date User Action Args
2026-06-08 19:39:48adminsetmessages: + msg8599
2026-06-05 00:00:00admincreate