[cfe-commits] New files for libcxxabi
Marshall Clow
mclow.lists at gmail.com
Wed Jun 8 12:12:37 PDT 2011
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_vector.cpp
Type: application/octet-stream
Size: 11256 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20110608/5363ec01/attachment.obj>
-------------- next part --------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cxa_vector.cpp
Type: application/octet-stream
Size: 12490 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20110608/5363ec01/attachment-0001.obj>
More information about the cfe-commits
mailing list