<div dir="ltr"><div><div>Thanks to all. I wrote a test case to see if the constructor of outermost variable completes before destructor of inner temporaries is called.<br><br><i>int as;<br>struct a {<br> a () { printf("Construct A\n"); }<br>
<br> ~a () NOEXCEPT_FALSE { printf("Destruct A\n"); throw 42; }<br>};<br><br>int f (a const&) { return 1; }<br><br>struct b {<br> b (...) { printf("Construct B\n"); }<br> ~b () { printf("Destruct B\n"); }<br>
<br> int x(){return 1;}<br>};<br><br>int main () {<br> thrown = 0;<br> try {<br> printf("%d\n",b(f(a())).x());<br> }<br> catch (...) {}<br><br>}<br><br></i></div>Output with clang :<br><br><i>Construct A<br>
Construct B<br>1<br>Destruct B<br>Destruct A<br><br><br></i></div><div>This indicates that Constructor of outermost object completes before destructor of inner temporaries is called (as it was able to call function x() ).<br>
</div><div><br>As per the link provided by Richard, it is not yet clear what should be the order of destructor to be called. <br>GCC calls destructor of outer local variable as soon as the destructor of any one of the temporaries throws, destructor of other temporaries are called later. <br>
This is not easy to achieve in clang with EHStack approach. <br><br></div><div>Now as we are not sure of the order of destructors to be called, should we approach with '<i>full-expression storage duration objects are destroyed before automatic storage duration objects in all cases</i>', which would be achievable with EHStack approach? Because right now, as the destructor of local variable is not called at all (in our original test case 'init-temp1.C'), there is a resource leak. Or should we wait for things to get clear and then only go ahead for solving this bug?</div>
<div class="gmail_extra">
<br clear="all"><br>-- <br>With regards,<br>Suyog Sarda<br>
</div></div>