From: Jason Merrill Date: Tue, 20 Mar 2001 16:59:44 +0000 (-0500) Subject: vec.cc (__cxa_vec_cleanup): New fn. X-Git-Tag: prereleases/libstdc++-2.92~319 X-Git-Url: https://gcc.gnu.org/git/?a=commitdiff_plain;h=f8c02bc55a20d70e5edc71b42129909324eb5c8e;p=gcc.git vec.cc (__cxa_vec_cleanup): New fn. * libsupc++/vec.cc (__cxa_vec_cleanup): New fn. (__cxa_vec_ctor, __cxa_vec_cctor, __cxa_vec_dtor): Call it. * libsupc++/cxxabi.h: Declare it. From-SVN: r40657 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index f6d3bc3bb38d..7ab9839fc8cf 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,9 @@ +2001-03-20 Jason Merrill + + * libsupc++/vec.cc (__cxa_vec_cleanup): New fn. + (__cxa_vec_ctor, __cxa_vec_cctor, __cxa_vec_dtor): Call it. + * libsupc++/cxxabi.h: Declare it. + 2001-03-16 Alexandre Oliva * src/gen-num-limits.cc (signal_adapter): Overloaded to match diff --git a/libstdc++-v3/libsupc++/cxxabi.h b/libstdc++-v3/libsupc++/cxxabi.h index e533f4de7718..1d4464a274e9 100644 --- a/libstdc++-v3/libsupc++/cxxabi.h +++ b/libstdc++-v3/libsupc++/cxxabi.h @@ -473,6 +473,13 @@ void __cxa_vec_dtor (void *__array_address, __SIZE_TYPE__ __element_size, void (*__destructor) (void *)); +/* destruct array */ +extern "C" +void __cxa_vec_cleanup (void *__array_address, + __SIZE_TYPE__ __element_count, + __SIZE_TYPE__ __element_size, + void (*__destructor) (void *)); + /* destruct and release array */ extern "C" void __cxa_vec_delete (void *__array_address, diff --git a/libstdc++-v3/libsupc++/vec.cc b/libstdc++-v3/libsupc++/vec.cc index 8ee893bb5963..037d052bae69 100644 --- a/libstdc++-v3/libsupc++/vec.cc +++ b/libstdc++-v3/libsupc++/vec.cc @@ -150,7 +150,7 @@ namespace __cxxabiv1 { { uncatch_exception ue; - __cxa_vec_dtor(array_address, ix, element_size, destructor); + __cxa_vec_cleanup(array_address, ix, element_size, destructor); } __throw_exception_again; } @@ -180,7 +180,7 @@ namespace __cxxabiv1 { { uncatch_exception ue; - __cxa_vec_dtor (dest_array, ix, element_size, destructor); + __cxa_vec_cleanup(dest_array, ix, element_size, destructor); } __throw_exception_again; } @@ -197,10 +197,9 @@ namespace __cxxabiv1 { char *ptr = static_cast(array_address); std::size_t ix = element_count; - bool unwinding = std::uncaught_exception(); - + ptr += element_count * element_size; - + try { while (ix--) @@ -211,19 +210,46 @@ namespace __cxxabiv1 } catch (...) { - if (unwinding) - // [except.ctor]/3 If a destructor called during stack unwinding - // exits with an exception, terminate is called. - std::terminate (); { uncatch_exception ue; - __cxa_vec_dtor(array_address, ix, element_size, destructor); + __cxa_vec_cleanup(array_address, ix, element_size, destructor); } __throw_exception_again; } } } + // 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 (array_address); + std::size_t ix = element_count; + + ptr += element_count * element_size; + + try + { + while (ix--) + { + ptr -= element_size; + destructor(ptr); + } + } + catch (...) + { + std::terminate(); + } + } + } + // Destruct and release array. extern "C" void __cxa_vec_delete(void *array_address,