std::terminate
Defined in header <exception> | ||
---|---|---|
void terminate(); | (until C++11) | |
[[noreturn]] void terminate() noexcept; | (since C++11) |
std::terminate()
is called by the C++ runtime when exception handling fails for any of the following reasons:
6) a dynamic exception specification is violated and the default handler for std::unexpected is executed 7) a non-default handler for std::unexpected throws an exception that violates the previously violated dynamic exception specification, if the specification does not include std::bad_exception | (until C++17) |
std::nested_exception::rethrow_nested
is called for an object that isn't holding a captured exceptionstd::thread
std::thread
is destroyed or assigned to11) a function invoked by a parallel algorithm exits via an uncaught exception and the execution policy specifies termination. | (since C++17) |
std::terminate()
may also be called directly from the program.
In any case, std::terminate
calls the currently installed std::terminate_handler
. The default std::terminate_handler
calls std::abort
.
If a destructor reset the terminate handler during stack unwinding and the unwinding later led to | (until C++11) |
If a destructor reset the terminate handler during stack unwinding, it is unspecified which handler is called if the unwinding later led to | (since C++11) |
Parameters
(none).
Return value
(none).
Defect reports
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
DR | Applied to | Behavior as published | Correct behavior |
---|---|---|---|
LWG 2111 | C++11 | effect of calling set_terminate during stack unwinding differs from C++98 and breaks some ABIs | made unspecified |
See also
the type of the function called by std::terminate (typedef) |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
http://en.cppreference.com/w/cpp/error/terminate