...
As such, deallocation functions (object, array, and placement forms at either global or class scope) must not be declared terminate by throwing an exception. Do not declare such functions to be noexcept(false)
but may instead , however it is acceptable to rely on the implicit noexcept(true)
specification or declare noexcept
explicitly on the function signature.
Object destructors are likely to be called during stack unwinding as a result of an exception being thrown. If the destructor itself throws an exception, having been called as the result of an exception being thrown, then the function std::terminate()
is called with the default effect of calling std::abort()
[ISO/IEC 14882-2014]. When std::abort()
is called, no further objects are destroyed, resulting in indeterminate program state and undefined behavior. Do not terminate a destructor by throwing an exception.
The C++ Standard, [class.dtor], paragraph 3, states [ISO/IEC 14882-2014]:
...