[exception.terminate] # 17 Language support library [[support]](./#support) ## 17.9 Exception handling [[support.exception]](support.exception#exception.terminate) ### 17.9.5 Abnormal termination [exception.terminate] #### [17.9.5.1](#terminate.handler) Type terminate_handler [[terminate.handler]](terminate.handler) [🔗](#lib:terminate_handler) `using terminate_handler = void (*)(); ` [1](#terminate.handler-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4010) The type of a [*handler function*](#def:handler_function) to be invoked by terminatewhen terminating exception processing[.](#terminate.handler-1.sentence-1) [2](#terminate.handler-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4016) *Required behavior*: A terminate_handler shall terminate execution of the program without returning to the caller[.](#terminate.handler-2.sentence-1) [3](#terminate.handler-3) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4021) *Default behavior*: The implementation's default terminate_handler callsabort()[.](#terminate.handler-3.sentence-1) #### [17.9.5.2](#set.terminate) set_terminate [[set.terminate]](set.terminate) [🔗](#lib:set_terminate) `terminate_handler set_terminate(terminate_handler f) noexcept; ` [1](#set.terminate-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4036) *Effects*: Establishes the function designated by f as the current handler function for terminating exception processing[.](#set.terminate-1.sentence-1) [2](#set.terminate-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4041) *Returns*: The previous terminate_handler[.](#set.terminate-2.sentence-1) [3](#set.terminate-3) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4045) *Remarks*: It is unspecified whether a null pointer value designates the defaultterminate_handler[.](#set.terminate-3.sentence-1) #### [17.9.5.3](#get.terminate) get_terminate [[get.terminate]](get.terminate) [🔗](#lib:get_terminate) `terminate_handler get_terminate() noexcept; ` [1](#get.terminate-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4059) *Returns*: The current terminate_handler[.](#get.terminate-1.sentence-1) [*Note [1](#get.terminate-note-1)*: This can be a null pointer value[.](#get.terminate-1.sentence-2) — *end note*] #### [17.9.5.4](#terminate) terminate [[terminate]](terminate) [🔗](#lib:terminate_) `[[noreturn]] void terminate() noexcept; ` [1](#terminate-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4075) *Effects*: Calls a terminate_handler function[.](#terminate-1.sentence-1) It is unspecified whichterminate_handler function will be called if an exception is active during a call to set_terminate[.](#terminate-1.sentence-2) Otherwise calls the current terminate_handler function[.](#terminate-1.sentence-3) [*Note [1](#terminate-note-1)*: A default terminate_handler is always considered a callable handler in this context[.](#terminate-1.sentence-4) — *end note*] [2](#terminate-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4087) *Remarks*: Called by the implementation when exception handling must be abandoned for any of several reasons ([[except.terminate]](except.terminate "14.6.2 The std​::​terminate function"))[.](#terminate-2.sentence-1) May also be called directly by the program[.](#terminate-2.sentence-2)