[cfe-commits] New files for libcxxabi
Marshall Clow
mclow.lists at gmail.com
Wed Jun 8 11:44:03 PDT 2011
On Jun 8, 2011, at 9:17 AM, Howard Hinnant wrote:
> On Jun 7, 2011, at 1:15 PM, Marshall Clow wrote:
>
>> Implements the new [] and delete [] functionality.
>> With tests.
>>
>> Comments please.
>> I'm not 100% sure that the exception handling is correct - so that's a good place to look ;-)
>
> This is looking pretty good to me. I have one trivial comment (1), and one non-trivial comment (2) that I'd like as many eyes as possible on.
>
> Thanks Marshall!
>
>
> 1. test_vector.cpp needs a standard LLVM/banner header.
>
> 2. In the catch clause of __cxa_vec_dtor:
>
> catch(...) {
> // if we've caught an exception while doing stack unwinding, then
> // there's really nothing we can do.
> if ( std::uncaught_exception ())
> std::terminate ();
> // otherwise, attempt to destruct the rest of the array and rethrow
> __cxa_vec_cleanup ( array_address, idx, element_size, destructor );
> throw ;
> }
>
> I'm thinking that even if we're in an unwind, we should still attempt __cxa_vec_cleanup:
>
> catch(...) {
> // attempt to destruct the rest of the array and rethrow
> __cxa_vec_cleanup ( array_address, idx, element_size, destructor );
> throw ;
> }
I think that this code is better - the call to uncaught_exception inside the catch block is wrong, I think.
> if ( NULL != destructor ) {
> char *ptr = static_cast <char *> (array_address);
> size_t idx = element_count;
> const bool is_unwinding = std::uncaught_exception ();
>
> ptr += element_count * element_size; // one past the last element
> try {
> while ( idx-- > 0 ) {
> ptr -= element_size;
> destructor ( ptr );
> }
> }
>
> catch(...) {
> // [15.2.3] If a destructor called during stack unwinding exits with
> // an exception, then std::terminate is called
> if ( is_unwinding )
> std::terminate ();
> // otherwise, attempt to destruct the rest of the array and rethrow
> __cxa_vec_cleanup ( array_address, idx, element_size, destructor );
> throw ;
> }
> }
-- Marshall
More information about the cfe-commits
mailing list