On Jun 8, 2011, at 11:46 AM, Howard Hinnant wrote:
> On Jun 8, 2011, at 11:44 AM, Marshall Clow wrote:
> 
>> 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 ;         
>>>       }
>>>   }
> 
> We should come up with a test that detects this and thus demonstrates the 
> need for it (or disproves the need for it).

New files - with tests.
Though having a test that calls 'terminate' is going to make it hard to put it 
into a test suite ;-)

-- Marshall

Attachment: test_vector.cpp
Description: Binary data

 

Attachment: cxa_vector.cpp
Description: Binary data

_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to