std::terminate
Min standard notice:
Header: <exception>
std::terminate() is called by the C++ runtime when the program cannot continue for any of the following reasons:
# Declarations
void terminate();
(until C++11)
[[noreturn]] void terminate() noexcept;
(since C++11)
# Notes
If the handler mechanism is not wanted, e.g. because it requires atomic operations which may bloat binary size, a direct call to std::abort is preferred when terminating the program abnormally.
Some compiler intrinsics, e.g. __builtin_trap (gcc, clang, and icc) or __debugbreak (msvc), can be used to terminate the program as fast as possible.
# Defect reports
| DR | Applied to | Behavior as published | Correct behavior |
|---|---|---|---|
| LWG 2111 | C++11 | effect of calling std::set_terminate during stackunwinding differs from C++98 and breaks some ABIs | made unspecified |