...
Do not explicitly or implicitly call std::quick_exit()
, std::abort()
, or std::_Exit()
. When the default terminate_handler
is installed or the current terminate_handler
responds by calling std::abort()
or std::_Exit()
, do not explicitly or implicitly call std::terminate()
. Abnormal process termination is the typical vector for denial-of-service attacks.
The std::exit()
function is more complex. The C++ Standard, [basic.start.main], paragraph 4, states:
Terminating the program without leaving the current block (e.g., by calling the function std::exit(int) (17.5)) does not destroy any objects with automatic storage duration (11.4.6). If std::exit is called to end a program during the destruction of an object with static or thread storage duration, the program has undefined behavior.
You may call It is acceptable to call a termination function that safely executes destructors and properly cleans up resources, such as std::exit()
only in a function that has not yet initialized any objects with automatic storage duration.
Noncompliant Code Example
...