2010/11/3 Marcin Świderski <[email protected]>

> W dniu 3 listopada 2010 12:15 użytkownik Zhongxing Xu <
> [email protected]> napisał:
>
>
>>
>> 2010/11/3 Marcin Świderski <[email protected]>
>>
>>> 2010/11/3 Zhongxing Xu <[email protected]>
>>>
>>>
>>>>
>>>> On Wed, Nov 3, 2010 at 2:19 PM, Marcin Swiderski <
>>>> [email protected]> wrote:
>>>>
>>>>> Author: sfider
>>>>> Date: Wed Nov  3 01:19:35 2010
>>>>> New Revision: 118158
>>>>>
>>>>> URL: http://llvm.org/viewvc/llvm-project?rev=118158&view=rev
>>>>> Log:
>>>>> Added generating destructors for temporary objects. Two cases I know
>>>>> of, that are not handled properly:
>>>>> 1. For statement: const C& c = C(0) ?: C(1) destructors generated for
>>>>> condition will not differ from those generated for case without prolonged
>>>>> lifetime of temporary,
>>>>> 2. There will be no destructor for constant reference member bound to
>>>>> temporary at the exit from constructor.
>>>>>
>>>>>
>>>> Hi Marcin,
>>>>
>>>> Could you please provide two examples for these cases?
>>>>
>>>
>>> Examples in attachment.
>>>
>>> In test_impl_cond() you can see that when assigning expression result to
>>> regular variable both temporaries are destroyed and this is correct. But
>>> when assiging to constant reference, temporary in condition should be
>>> destroyed only when false branch is taken.
>>>
>>
>> There are other problems in this example. There are two dtors in B6. One
>> is due to an elidable CXXConstructExpr. Maybe we should not add
>> CXXBindTemporaryExpr whose subexpr is an elidable CXXConstructExpr.
>>
>
> Elidable CXXConstructExpr should inhibit calling destructor for temporary
> that is copied, not the one created. This is because eliding copy
> constructor means that the object that was to be copied will be constructed
> directly in memory the copy would be constructed in. Doing this as you
> propose will work fine for eliding copy from temporary to temporary (balance
> between ctors and dtors will be preserved), but won't work for eliding copy
> from temporary to variable (there will be one more dtor called).
>

Hi Marcin,

I finally understood your point. Thanks for giving such a lucid explanation.
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to