GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::terminate(3) C++ Standard Libary std::terminate(3)

std::terminate - 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 the program cannot continue 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) a function directly invoked by the exception handling mechanism while handling an
exception that has not yet been caught exits via an exception (e.g. a destructor of
some local object, or a copy constructor constructing a catch-clause parameter)
3) the constructor or the destructor of a static
or thread-local
(since C++11) object throws an exception
4) a function registered with std::atexit
or std::at_quick_exit
(since C++11) throws an exception


5) a dynamic exception specification is violated and the default
handler for std::unexpected is executed
6) a non-default handler for std::unexpected throws an exception that (until C++17)
violates the previously violated dynamic exception specification, if
the specification does not include std::bad_exception


7) a noexcept specification is violated (it is implementation-defined
whether any stack unwinding is done in this case)
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 (since C++11)
10) a joinable std::thread is destroyed or assigned to
11) std::condition_variable::wait,
std::condition_variable::wait_until, or
std::condition_variable::wait_for fails to reach its postcondition
(e.g. if relocking the mutex throws)


12) a function invoked by a parallel algorithm exits via an uncaught (since C++17)
exception and the execution policy specifies termination.


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 terminate being called, the handler that
was installed at the end of the throw expression is the one that will (until C++11)
be called. (note: it was ambiguous whether re-throwing applied the new
handlers)
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)
terminate being called.


(none)


(none)


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


The following behavior-changing defect reports were applied retroactively to
previously published C++ standards.


DR Applied to Behavior as published Correct behavior
effect of calling set_terminate during stack
LWG 2111 C++11 unwinding differs from C++98 and breaks some made unspecified
ABIs


terminate_handler the type of the function called by std::terminate
(typedef)
abort causes abnormal program termination (without cleaning up)
(function)

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.