<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/67074>67074</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Object destruction while stack-unwinding are not accorded to standard
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
DKay7
</td>
</tr>
</table>
<pre>
I was solving cpp-quiz and have [question](https://cppquiz.org/quiz/question/323?result=OK&answer=bcad&did_answer=Answer) with followed code:
```cpp
#include <iostream>
#include <stdexcept>
struct A {
A(char c) : c_(c) {}
~A() { std::cout << c_; }
char c_;
};
struct Y { ~Y() noexcept(false) { throw std::runtime_error(""); } };
A f() {
try {
A a('a');
Y y;
A b('b');
return {'c'};
} catch (...) {
}
return {'d'};
}
int main()
{
f();
}
```
According to standard, program's output should be `bcad`. But clang-18 produces just `bad`. I performed some tests and found out that A-object with `'c'` value was never destructed. Order of construction and destruction that I get is:
```
a CONSTRUCTED
b CONSTRUCTED
c CONSTRUCTED
b DESTRUCTED
a DESTRUCTED
d CONSTRUCTED
d DESTRUCTED
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxsVE1v4zYQ_TXUZWBDJi3LOuggRzEQLNAA7faQU0CRY4tbmdTyI2562N9ekFJiex1A0MfwvXmPoxly59RRI9ak2JGizXjwvbF1-42_l1ln5Hv9BGfuwJnhTekjiHFc_AzqP-BaQs_fEEix-xnQeWU0KVpCt733oyOsIXRP6F6MY8QvjT0Suo-v6TET6J5RRtjeoguDJ6x9_kbohmt3RktY2wkuCd1IJV8_Y830Qis4K9_DwQyDOaMEYSRG1bwleQPTg2zy6RLjOEcoU1oMQSIQ9qCM8xb5ibDHr5adl_ivwNFf1tPdeRuEhwZIuZv1AKAhdCt6bkFEc4Q1IF5jKH2VO1K2F-yvCJ4XwHkZjbNGmOCjLmEPkct2cEOaksf4bKZsL-_Xxl5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