[except.special] (original) (raw)

14 Exception handling [except]

14.6 Special functions [except.special]

14.6.1 General [except.special.general]

The function std​::​terminate ([except.terminate]) is used by the exception handling mechanism for coping with errors related to the exception handling mechanism itself.

The function std​::​uncaught_exceptions ([uncaught.exceptions]) reports how many exceptions are uncaught in the current thread.

The function std​::​current_exception ([propagation]) and the classstd​::​nested_exception ([except.nested]) can be used by a program to capture the currently handled exception.

14.6.2 The std​::​terminate function [except.terminate]

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.

[Note 1:

These situations are:

— _end note_]

In the situation where no matching handler is found, it isimplementation-defined whether or not the stack is unwound before std​::​terminate is invoked.

In the situation where the search for a handler ([except.handle]) exits the function body of a function with a non-throwing exception specification ([except.spec]), it isimplementation-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​::​terminateis 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 functionstd​::​terminate.