<div class="gmail_quote">W dniu 3 listopada 2010 12:15 użytkownik Zhongxing Xu <span dir="ltr"><<a href="mailto:xuzhongxing@gmail.com">xuzhongxing@gmail.com</a>></span> napisał:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br><br><div class="gmail_quote"><div class="im">2010/11/3 Marcin Świderski <span dir="ltr"><<a href="mailto:marcin.sfider@gmail.com" target="_blank">marcin.sfider@gmail.com</a>></span><br></div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">

<div class="gmail_quote">2010/11/3 Zhongxing Xu <span dir="ltr"><<a href="mailto:xuzhongxing@gmail.com" target="_blank">xuzhongxing@gmail.com</a>></span><div class="im"><div><div></div><div><br><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">


<br><br><div class="gmail_quote"><div>On Wed, Nov 3, 2010 at 2:19 PM, Marcin Swiderski <span dir="ltr"><<a href="mailto:marcin.sfider@gmail.com" target="_blank">marcin.sfider@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">
Author: sfider<br>
Date: Wed Nov  3 01:19:35 2010<br>
New Revision: 118158<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=118158&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=118158&view=rev</a><br>
Log:<br>
Added generating destructors for temporary objects. Two cases I know of, that are not handled properly:<br>
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,<br>
2. There will be no destructor for constant reference member bound to temporary at the exit from constructor.<br><br></blockquote></div><div><br>Hi Marcin,<br><br>Could you please provide two examples for these cases? <br>


</div>
</div>
</blockquote></div></div></div></div><div class="im"><br><div>Examples in attachment.</div><div><br></div><div>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.</div>

</div></blockquote><div><br>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.<br>

</div></div></blockquote><div><br></div><div>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).</div>
<div><br></div><div>Balance between ctors and dtors is more important IMO, so I wouldn't do this way.</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="gmail_quote">
<div> </div><div class="im"><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">
<div><br></div><div>In TestConstRefMember constructor temporary is created and should be destroyed at the exit from constructor (after "int b").</div>
</blockquote></div></div><br>
</blockquote></div><br>