std::terminate

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

DRApplied toBehavior as publishedCorrect behavior
LWG 2111C++11effect of calling std::set_terminate during stackunwinding differs from C++98 and breaks some ABIsmade unspecified

# See also