TITLE: exceptions in constructors (Newsgroups: comp.lang.c++.moderated, 21 Jan 98) HOPPS: "Kevin J. Hopps" >[...] consider this: > { Thing* array = new Thing[3]; delete [] array; } >When delete is called, the destructor for array[2] is called, then >array[1] and array[0], and finally the memory is released. What if the >destructor for array[2] throws? Are the other objects destroyed? Is >the memory released? BELL: abell@mindspring.com (Andrew Bell) Section 15.2 of the draft is quite clear on this: 2 An object that is partially constructed will have destructors executed only for its fully constructed sub-objects. Should a constructor for an element of an automatic array throw an exception, only the constructed elements of that array will be destroyed. If the object or array was allocated in a new-expression and the new-expression does not contain a new-placement, the deallocation function (_basic.stc.dynamic.deallocation_, _class.free_) is called to free the storage occupied by the object; the deallocation function is chosen as specified in _expr.new_. If the object or array was allocated in a new-expression and the new-expression contains a new-placement, the storage occupied by the object is deallocated only if an appropriate placement operator delete is found, as specified in _expr.new_