Post

Replies

Boosts

Views

Activity

Cannot catch `std::invalid_argument` on clang++ under m1 -fno-rtti
Today I got stuck with a weird behaviour with my c++ project. There is the code which doesn't catch exception from standard library (the same snippet works well on intel mac and under linux machines). Code snippet: #include <exception> #include <stdexcept> #include <iostream> #include <string> int main() { try { std::stod("notanumber"); } catch (const std::invalid_argument&) { std::cerr << "Caught std::invalid_argument" << std::endl; } } Compilation command: clang++ -fno-rtti main.cpp -o main && ./main Clang versions: clang++ --version Homebrew clang version 15.0.3 Target: arm64-apple-darwin21.6.0 Thread model: posix InstalledDir: /opt/homebrew/opt/llvm/bin Also tried: Apple clang version 14.0.0 (clang-1400.0.29.102) Target: arm64-apple-darwin21.6.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin Output: libc++abi: terminating with uncaught exception of type std::invalid_argument: stod: no conversion [1] 65643 abort ./main Expected output: Caught std::invalid_argument Other info: Chip: Apple M1 OS: 12.6
4
0
1.5k
Dec ’24