Destructor Exceptions Considered Harmful ---------------------------------------- 26-Jan-95 by Nathan Myers X3J16/95-0023 Rogue Wave Software WG21/0623 This is a very short proposal: I know of no way to handle cleanly the effect of an exception thrown from a destructor, particularly while destroying a vector of objects of unknown (e.g. parameterized) type. In particular, I know of no way to implement a standard library which can recover from such an event. Therefore, I recommend that we add to the front matter for the library the following text: "The effect of throwing an exception from the destructor of an object destroyed by any standard library function is undefined, except as documented for any particular function." Example of the problem: ----------------------- class E; class T { ~T() throw E; } // user types vector v; Imagine implementing vector. When an element is appended to the end, and storage must be reallocated, and the elements copied, what does one do if one has copied all the elements, and then begins to destroy the old elements, and a destructor throws? One then has two vectors, one containing a mix of raw storage, a partially destroyed element, and undestroyed elements. The storage cannot be reclaimed until all the destructors are called, the destructors must not be called out of order, and the destructor that threw cannot be called again.