<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/62062>62062</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Order of destructor call of temporary and __cxa_throw
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
strimo378
</td>
</tr>
</table>
<pre>
I might have found an issue with the order of destructor call of a temporary and the call to the __cxa_throw function within a throw statements.
In the following code, the clang frontend first calls __cxa_throw and afterwards a::~a. See https://godbolt.org/z/jbx74s1Ge
```
struct a {
~a() noexcept;
};
struct b {
b(a) noexcept;
};
void c() {throw b(a()); }
```
GCC generates it in opposite order which is more logical to me. ICC generates it in the same order as clang. I don't know what is correct from the C++ standard, maybe it is undefined.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyEU09vvDYQ_TTmMvohMH92OXDIbrTRnnroB4gGPIBTsFf2EJIe8tkrm02bVFErWV7vmDfvwZuH3uvRELWiOonqMcGVJ-taz04vtjgck86q9_YKix4nhglfCQa7GgVoQHu_EmyaJ-CJwDpFDuwAijy7tWfroMd5DiUEpuVmHbp3QKPi8_GObTw_P_dv-MyTsxsMq-lZWxM7axOwse4ZmRYy7FORPYrsYd-vJnYY7DzbTZsReqtIyPPOMaMZYXDWMBkFg3aeI7H_Rhkk4cDkNnTKA4riQRQPH5jC70QwMd98KMmLkJfRqs7OnFo3Cnn5U8jLS_d2KH3-RF9liTq7r_h3_yKAIA6nvQLwgUIehWzAWHrr6caiuN-Jw-Pf5zuy-4rshDzi_yJfrVbQ3znE4bS_6x0bimEVJwiYnzTv-9P5DCMZcsjkQTNoA_Z2s17zp-fbpPsJtIfFOoLZjrrHaO1CKVx_wAdrPC6fePS7USlcQVkj5IHhD2M32Cbk0Le3zlHPwcglgs9CnoQ8hZkwCp0Kfi_43lEk8LAaRYM2pNJEtYVqigYTavP6mMusPjRNMrVDVXcqGxqFTaVUmdVdhQ2WZVPKshqGOtGtzGSRlXmeNVWRN2ndZbms-2NZKcy7rBBlRgvqOZ3n1yXMQxIT0dYyq2UyY0ezj7mS0tC2x0VIGWLm2oD51a2jF2U2a8_-ny6seab2t_-I0_cwfZnkZHVz-6951TytXdrbRchL4Lj__Lo5-0I9C3mJyryQl6j8rwAAAP__IA1NCg">