+ // Destruct array as a result of throwing an exception.
+ // [except.ctor]/3 If a destructor called during stack unwinding
+ // exits with an exception, terminate is called.
+ extern "C" void
+ __cxa_vec_cleanup(void *array_address,
+ std::size_t element_count,
+ std::size_t element_size,
+ void (*destructor) (void *))
+ {
+ if (destructor)
+ {
+ char *ptr = static_cast <char *> (array_address);
+ std::size_t ix = element_count;
+
+ ptr += element_count * element_size;
+
+ try
+ {
+ while (ix--)
+ {
+ ptr -= element_size;
+ destructor(ptr);
+ }
+ }
+ catch (...)
+ {
+ std::terminate();
+ }
+ }
+ }
+