##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# std::terminate

From cppreference.com
< cpp‎ | error

Defined in header `<exception>` |  |

void terminate(); |  | (until C++11)
[[noreturn]] void terminate(); |  | (since C++11)

`std::terminate()` is called by the C++ runtime when exception handling fails for any of the following reasons:

1) an exception is thrown and not caught (it is implementation-defined whether any stack unwinding is done in this case)
2) an exception is thrown during exception handling (e.g. from a destructor of some local object, or from a function that had to be called during exception handling)
3) the constructor or the destructor of a static or thread-local object throws an exception
4) a function registered with std::atexit or std::at_quick_exit throws an exception
5) a noexcept specification is violated (it is implementation-defined whether any stack unwinding is done in this case)
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
8) std::nested_exception::rethrow_nested is called for an object that isn't holding a captured exception
9) an exception is thrown from the initial function of std::thread
10) a joinable std::thread is destroyed or assigned to

`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.

### [edit] Parameters

(none)

### [edit] Return value

(none)

### [edit] Exceptions

(none) | (until C++11)
`noexcept` specification: noexcept | (since C++11)

### [edit] See also

terminate_handler | the type of the function called by std::terminate (typedef) [edit]

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=cpp/error/terminate&oldid=71867"
Category:

- unconditionally noexcept