Consider the following code:
class widget{public: ... ~widget () {...} // Suppose this might spit out an anomaly . }; void dosomething () { std::vector<Widget>v; } // V is destroyed here .
When Vector v is destroyed, it is responsible for destroying all the widgets it contains. Suppose V contains 10 widgets, and during the first element of the destructor, an exception is thrown. The other nine widgets should still be destroyed, so v should call each of their destructors. Suppose that during a call, the second widget destructor throws an exception. Now there are two simultaneous exceptions, which is too much for C + +. In the case where both exceptions exist, the procedure is not an end in execution, which results in ambiguous behavior. In this case, it leads to ambiguous behavior. A container or array is not a necessary condition for trouble, as long as the destructor highlights the exception, even if the container or arrays is not used, the program may end prematurely or appear ambiguous.
What if your destructor must perform an action that might throw an exception on failure?
"Effective C + +"-clause 08: Don't let exceptions escape destructors