__cxa_vec_new2 and deallocation functions that throw exceptions

Mark Mitchell mark at codesourcery.com
Wed May 14 18:37:25 UTC 2003


The ABI says that, for __cxa_vec_new2 and __cxa_vec_new3:

  If dealloc throws an exception, the result is undefined.

I don't understand this restriction.  In particular, the ISO C++
standard says (if I read it correctly) that:

  struct S {
    S() { throw 1; }
    void* operator new[] (size_t s) { return ::operator new[] (s); }
    void operator delete[] (void*) { throw 2; }
  };

  new S[5];

results in a call to std::terminate.  (First, the array is allocated,
then the elements are constructed, but the first one throws an
exception, which causes the deallocation function to be called, which
throws an exception, so terminate is called.)

Shouldn't __cxa_vec_new[23] be required to call std::terminate if
dealloc throws an exception?

-- 
Mark Mitchell
CodeSourcery, LLC
mark at codesourcery.com




More information about the cxx-abi-dev mailing list