<div dir="ltr">Ok. sorry for my silly question above. i tested the code for the question i had, and it seems that destructor of all temporaries <div>as well as other objects created before the current line are being called when exception occurs, except the destructor of the </div>

<div>outermost object. </div><div><br></div><div>From the discussion in the link shared in the previous mail and the results of the test case, i conclude that for </div><div>clang, outermost object <i>temp </i>of class <i>b </i>is not considered constructed until all the inner temporaries are destroyed.<br>
</div>
<div><br></div><div>Since the outermost 'temp' is considered yet to be constructed fully, its destructor is not pushed in '<i>EHStack</i>'. </div><div>As a result whenever exception occurs in the destructor of temporaries, the EHStack does not contain destructor of outermost</div>

<div>object and hence its cleanup doesn't take place. </div><div><br></div><div>Please correct me if i am wrong? Also, while debugging i came across, following piece of code,</div><div><br><pre style="font-size:13px;background-color:rgb(245,245,245);margin:4px 8px 4px 2px;font-family:Fixed,monospace;padding:4px 6px;border:1px solid rgb(204,204,204)">
<i><span style="color:rgb(96,64,32)">void</span> <a href="http://clang.llvm.org/doxygen/classclang_1_1CodeGen_1_1CodeGenFunction.html#a079ab0affd32c3e7d992d8421776b732" style="color:rgb(0,0,255);text-decoration:none" target="_blank">CodeGenFunction::EmitCXXTryStmt</a>(<span style="color:rgb(0,128,0)">const</span> <a href="http://clang.llvm.org/doxygen/classclang_1_1CXXTryStmt.html" style="color:rgb(0,0,255);text-decoration:none" target="_blank">CXXTryStmt</a> &<a href="http://clang.llvm.org/doxygen/AnalysisBasedWarnings_8cpp.html#a33dc45a03958a0bf07b5da2dec4db648" style="color:rgb(0,0,255);text-decoration:none" target="_blank">S</a>) {
        <a href="http://clang.llvm.org/doxygen/classclang_1_1CodeGen_1_1CodeGenFunction.html#ae064b29757ae2b6085d4df62ea2df530" style="color:rgb(0,0,255);text-decoration:none" target="_blank">EnterCXXTryStmt</a>(S);
        <a href="http://clang.llvm.org/doxygen/classclang_1_1CodeGen_1_1CodeGenFunction.html#ab625dabfdcc8082335d64c4cbd009ef0" style="color:rgb(0,0,255);text-decoration:none" target="_blank">EmitStmt</a>(S.<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXTryStmt.html#a0b14fc308d0e5f78e4f2bd425fc308da" style="color:rgb(0,0,255);text-decoration:none" target="_blank">getTryBlock</a>());
        <a href="http://clang.llvm.org/doxygen/classclang_1_1CodeGen_1_1CodeGenFunction.html#ac1f782050e59094db58fbbd1b9e3f8c1" style="color:rgb(0,0,255);text-decoration:none" target="_blank">ExitCXXTryStmt</a>(S);
 }</i></pre><br></div><div class="gmail_extra"> <br>which after several function calls in between leads me to below (for init-temp1.C test code) :<br><br><i>CodeGenFunction::emitAutoVarTypeCleanup</i><br>{<br>.....<br><i>// Use an EH cleanup in array destructors iff the destructor itself<br>
  // is being pushed as an EH cleanup.<br>  bool useEHCleanup = (cleanupKind & EHCleanup);<br>  EHStack.pushCleanup<DestroyObject>(cleanupKind, addr, type, destroyer,<br>                                     useEHCleanup);</i><br>
}<br><br></div><div class="gmail_extra">At this point the destructor is pushed to EHStack.<i> </i>When i traced the code for init-temp1.C, i hit the <i>EHStack.pushcleanup </i>function above<i>, </i>still the destructor of outermost object is not being called. <br>
<br></div><div class="gmail_extra">Can someone please help me if i am looking at right place? If my analysis for clang is right - outermost object not considered created until innermost temporaries are destroyed - where should i look to correct this problem?<br>
<br></div><div class="gmail_extra">If by design, clang doesn't consider outermost object to be created until inner temporaries are destroyed, would this be a resource leak<i> </i>(i don't think it is leak, as the object is yet to be constructed, hence no destruction required)?<br>
<br></div><div class="gmail_extra">Your help would be highly appreciated.<i>  <br></i></div><div class="gmail_extra"><br>-- <br>With regards,<br>Suyog Sarda<br>
</div></div>