Open
Description
System Info
- OS: macos 12.6.5
- arch: Apple silicon
Compiler info
- Homebrew clang version 18.1.5
- Target: arm64-apple-darwin21.6.0
- Thread model: posix
- InstalledDir: /opt/homebrew/Cellar/llvm/18.1.5/bin
Problem description
When an exception of custom type is thrown in the constructor for a class, and that constuctor gets invoked in the return
statement of a function, this exception cannot be caught in the calling code.
So far the exact circumstances under which this happens or does not happen are unknown to me, but I have attached a small CMake project to demonstrate.
The problem does not occur with std::runtime_error
, only with a subclass.
How to run
export CC=/opt/homebrew/Cellar/llvm/18.1.5/bin/clang CXX=/opt/homebrew/Cellar/llvm/18.1.5/bin/clang++
cmake ..
make && ./test
Result
ld: warning: dylib (/opt/homebrew/opt/llvm/lib/c++/libc++.dylib) was built for newer macOS version (12.7) than being linked (12.6)
[100%] Built target test
Throwing
libc++abi: terminating due to uncaught exception of type Error: hallo
Abort trap: 6
Minimal reproducible project
Here is a minimal cmake project (with build artifacts on my machine, in case that is relevant)