This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 119a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2025-12-20
[Voted into WP at April 2003 meeting.]
In a couple of comp.std.c++ threads, people have askedwhether the Standard guarantees that the deallocation functionwill be called in a delete-expression if the destructor throwsan exception. Most/all people have expressed the opinion thatthe deallocation function must be called in this case, althoughno one has been able to cite wording in the Standard supportingthat view.
#include <new.h>#include <stdio.h>#include <stdlib.h>static int flag = 0;inlinevoid operator delete(void* p) throw(){ if (flag) printf("in deallocation function\n"); free(p);}struct S { ~S() { throw 0; }};void f() { try { delete new S; } catch(...) { }}int main() { flag=1; f(); flag=0; return 0;}Proposed resolution (October 2002):
Add to 7.6.2.9 [expr.delete] paragraph 7 the highlighted text:
Thedelete-expression will call adeallocation function(6.8.6.5.3 [basic.stc.dynamic.deallocation])[Note: The deallocation function is called regardless ofwhether the destructor for the object or some element of the arraythrows an exception. ]