<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/55032>55032</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Missing implicit handler for terminate call from __cxa_vec_dtor
</td>
</tr>
<tr>
<th>Labels</th>
<td>
libc++abi
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
hubert-reinterpretcast
</td>
</tr>
</table>
<pre>
N4910 subclause 14.4 [except.handle] paragraphs 7 and 8:
> [ ... ] an implicit handler is considered active when the function std::terminate is entered due to a throw. [ ... ] The exception with the most recently activated handler that is still active is called the _currently handled exception_.
With libc++abi, if an exception throws from more than one destructor called from `__cxa_vec_dtor`, a call to terminate occurs; however, the currently handled exception within the terminate handler is not updated to match the exception being thrown such that `terminate` is called.
The GNU runtime library has no such problem.
Online compiler link: https://godbolt.org/z/rYvrM554W
### SOURCE (`<stdin>`):
```
#include <cxxabi.h>
struct A {
~A() noexcept(false) {
static int cnt;
if (cnt++)
throw 0.f;
throw 0;
}
};
void dtorfunc(void *p) { static_cast<A *>(p)->~A(); }
int main(void) {
try {
throw L'\0';
} catch (...) {
try {
__cxxabiv1::__cxa_vec_dtor(new A[2], 2u, sizeof(A), dtorfunc);
} catch (...) {}
}
}
```
### COMPILER INVOCATION COMMAND:
```
clang++ -stdlib=libc++ -xc++ -
```
### RUN INVOCATION:
```
./a.out
```
### ACTUAL RUN OUTPUT:
```
libc++abi: terminating with uncaught exception of type wchar_t
```
### EXPECTED RUN OUTPUT:
```
libc++abi: terminating with uncaught exception of type float
```
### COMPILER VERSION INFO (`clang++ -v`):
```
clang version 15.0.0 (https://github.com/llvm/llvm-project.git a0d40a579a6f27a1b1cdb7d68b2145e332c02c4e)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/wandbox/clang-head/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Candidate multilib: .;@m64
Selected multilib: .;@m64
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy1Vltv6jgQ_jXhxSIKDuHywEPK5ahSC1UPnLP7hBzHEO8xNrIdSs-v35kESKHbqivtSlx8m5lvvhnPODP562jeHXYi4sqMK1Y6QTrdsEuC5E4cudj7sGA6VyJIJmTPLNtati8c6RNYJYMgToNoEkRpEE9RhIRhSPAo00Tu9kpy6UmtwBLpCDfayVxYkRPGvTwI8lIITXwhyKbUsGI0cT5HtXHqhd1JzbxASaF9JZaXgnhDGMhY8xJeGV2Cmho06nmRvqg074zzxAoOKtRrbReU5hdcvmAeTTgvlTrjQrBMKTiGKta8tLaWr6XyxtA6PFFQ_f5Eq0pmPKB38GGZDOiYyA0y0mCrwDuysWYH8KxADJoYLUgunLcl98ae7VeHgl60XvMjWx8EX-ewCwuomFWnkJGGLcMBrQviO1KYF3EQFg-iF584UbEl60g0mt5EThtPyn1eEQfWdszzmt1GRSak3tauQRTLah-YBaQXjTBumD3xhlH7Nl8RW2ovdwLJs8wiRrRaK9pbkymxu2J6oZUEwrjZ7SWChNkvyBpSeL93mEF0Bp-tyTOjfGjsFma_4Wv_PNjHJOn-fKssoHH9Id8Xq-cxJDMdIMXxGNJRakjvivBhk_AwrT9neam5KnNBQIYfjxD4sECxaruOKUlJ0L-rVwgMpylaoUNws2YRphumnMC1NycJpCbzkhOpPeHaQ2ibLUgtEMPVKuEQ42WP1NEgUbi5kjmtvlkL-pOTIzA4Lx-MhAsHyYZ3E4xU84Cm-xO-E6w1Zw4wjVPcQ5fpAE-0cXjxEdPxYgT92DGgtdZ5466H4F95X8N9CGg_SMYR_l0Bh3TCZARlUAjeUfdOGyF4kzBAh05daG5uFh1o8UJSqCwUqgpeHlrir5O_hdnAdor-wEJDzfCK3o8wnd2_ofsf8-kmK8eLx6f7h-kzuZ__WIzT5f1ijmuP6XzyUUpCNdfbOilIG7IY7lUQT5rSRNrHy-hLGJ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