<br><br><div class="gmail_quote">On Mon, Sep 3, 2012 at 7:46 AM, SENTHIL KUMAR THANGAVELU <span dir="ltr"><<a href="mailto:senthil.t@samsung.com" target="_blank">senthil.t@samsung.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





<div style="WORD-WRAP:break-word">
<p>Hello all,<br>   I had looked into bug 12306 <a href="http://llvm.org/bugs/show_bug.cgi?id=12306" target="_blank">http://llvm.org/bugs/show_bug.cgi?id=12306</a> specifically init-temp1.C (attached test case in mail). There is a problem with the following snippet, when compiled with clang 3.1 release<br>
   <br>     try {<br>       b tmp(f (a(), a()));<br>   <br>       g();<br>     }  <br>     catch (...) {}<br>     <br>     In expression "b tmp(f (a(), a()));" if first temporary object a() throws an exception, object "tmp" is not cleaned up. Issue seems to be absence of ehcleanup entry for object "tmp" in the EhStack, when PopCleanupBlocks is called via VisitExprWithCleanups. Cleanup code for the 2 temporary "a()" objects are emitted when VisitExprWithCleanups node is visited, whereas autovar object "tmp"'s cleanup code is emitted by lexical scope cleaning. Association between the cleanup of temporary a() objects and the cleanup of auto var decl depending on the temporary objects is missing.</p>

<p>     I tried pushing object "tmp" cleanup entry (kind == EHCleanup) on top of EhStack when a() objects' cleanup entries are also present in the EHStack. I did this to check whether cleanup code for freeing "tmp" will be emitted, when first temporary's destructor threw an exception. After my code change object tmp was destroyed when object a()'s destructor threw an exception. There were 2 problems with the generated code.<br>
     <br>     1) Second temporary object a() was destroyed before object "tmp" got destroyed<br>     2) Apart from the destructor, even if the constructor of a() failed, call to cleanup "tmp" was emitted via landingpad<br>
     <br>     I could see that the landing pads generated are symmetric for an object's constructor and destructor e.g if an object's constructor had lpad3 as landing pad, its destructor also had lpad3 as landing pad. In case of temporary object cleanup I need some functionality like if constructor threw exception use landing pad lpad_X. If destructor threw then use landing pad lpad_Y. If this has been done before, any suggestions on which part of code can I refer to for an example implementation? All other general comments on other approaches to fix this issue are also welcome.<br>
<br> Regards<br> Senthil Kumar<br></p></div><img src="" border="0" height="0" width="0"><br>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div>I have a big doubt suddenly: what do you mean by cleanup ?<br><br>If a call to `a()` throws, then `f` is never called, and thus `tmp` is never built (and since it never lives, it cannot be destructed).<br>
<br>-- Matthieu<br>