...
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 an indeterminate program state and undefined behavior. Do not terminate a destructor by throwing an exception.
...
SEI CERT C++ Coding Standard | ERR55-CPP. Honor exception specifications ERR50-CPP. Do not abruptly terminate the program |
MISRA C++:2008 | Rule 15-5-1 (Required) |
Bibliography
[Henricson 971997] | Recommendation 12.5, Do not let destructors called during stack unwinding throw exceptions |
[ISO/IEC 14882-2014] | Subclause 3.4.7.2, "Deallocation Functions" |
[Meyers 2005] | Item 8, "Prevent Exceptions from Leaving Destructors" |
[Sutter 2000] | "Never allow exceptions from escaping destructors or from an overloaded operator delete() " (p. 29) |
...