TICS Coding Standard Viewer 
TIOBE Software Quality Framework
Print-friendly version
©TIOBE Software www.tiobe.com
C++ Coding Standard

Rule:  ERR#001Checked automatically with code checker

Synopsis:Do not let destructors throw exceptions
Severity Level:1
Category:Error Handling


In contrast to what is said in ISC++, do not rely on the std::uncaught_exception function. That function is not always properly implemented by mainstream compilers. Furthermore, there are certain situations where this function is actually useless for the purpose it is intended for!

Any destructor can be called as a result of stack-unwinding due to an exception. If that destructor would throw another exception by itself, then the program will terminate without further cleanup handling. That is almost never a desirable situation. Therefor, destructors shall never throw an exception.

Note that a function called by a destructor is allowed to throw an exception! As long as you make sure that the destructor handles any exception if that might be thrown by its implementation.