-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Open
Labels
libc++abilibc++abi C++ Runtime Library. Not libc++.libc++abi C++ Runtime Library. Not libc++.
Description
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
Metadata
Metadata
Assignees
Labels
libc++abilibc++abi C++ Runtime Library. Not libc++.libc++abi C++ Runtime Library. Not libc++.