Actions

icon Post
text/html Subscribe
text/html Unsubscribe

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

__cxa_vec_new2 and deallocation functions that throw exceptions


  • To: cxx-abi-dev@xxxxxxxxxxxxxxxx
  • Subject: __cxa_vec_new2 and deallocation functions that throw exceptions
  • From: Mark Mitchell <mark@xxxxxxxxxxxxxxxx>
  • Date: 14 May 2003 11:37:25 -0700

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@xxxxxxxxxxxxxxxx