-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to catch exceptions with clang++ 18.1.5 on macos ARM (try-catch does nothing) #92121
Comments
@llvm/issue-subscribers-clang-codegen Author: Rasmus (themightyoarfish)
# System Info
Compiler info
Problem descriptionWhen an exception of custom type is thrown in the constructor for a class, and that constuctor gets invoked in the 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 How to run
Result
Minimal reproducible projectHere is a minimal cmake project (with build artifacts on my machine, in case that is relevant) |
I am also seeing this on LLVM 18.1.2 and libc++abi. edit: Only when I am using dynamic linking. |
I bisected this to 8f90e69. |
From Homebrew/homebrew-core#175994, you can fix this by linking directly with the same --- CMakeLists.txt.old 2024-07-24 12:29:07
+++ CMakeLists.txt 2024-07-24 12:29:32
@@ -6,6 +6,7 @@
add_library(wtf src/lib.cpp)
target_include_directories(wtf PUBLIC ${CMAKE_CURRENT_LIST_DIR}/include/)
+target_link_libraries(wtf PRIVATE /opt/homebrew/opt/llvm/lib/libunwind.dylib)
add_executable(test src/main.cpp)
target_link_libraries(test PRIVATE wtf) My guess is that |
This thread helped me figure out how to get if(CMAKE_SYSTEM_NAME MATCHES "Darwin"
AND CMAKE_SYSTEM_PROCESSOR MATCHES "arm64"
AND CMAKE_CXX_COMPILER_ID MATCHES "Clang"
AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 18)
link_libraries(/opt/homebrew/opt/llvm/lib/libunwind.dylib)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/opt/homebrew/opt/llvm/lib/c++")
endif() Note I'm also having issues trying to use the stdlib with LLVM 18 installed via Homebrew. Calling things like AFAICT everything works fine once I add those settings near the top of my |
Footnotes |
Thanks for the info. For some reason it just works with LLVM 17 and Homebrew. I didn't need to do anything special to use I want to say Homebrew is correctly setting up the LLVM stdlib for v17 installs, but is not doing so for v18 installs. But I really don't know what's going on with this stuff. Along with the Reddit post, I found several other people running into this issue, and it isn't a problem with LLVM 17, so it seems like a regression? I didn't mean to distract from the issue at hand here, but there is a clear difference in behavior between LLVM 17 and 18 installed by Homebrew w.r.t. locating the correct stdlib for clang++. |
No, there isn't. As far as I can tell, there has been a change in the implementation of Edit: Yup, it looks like this is exactly what happened. See 872fe20 and #80464. |
Recommended at: llvm/llvm-project#92121 (comment)
System Info
Compiler info
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
Minimal reproducible project
Here is a minimal cmake project (with build artifacts on my machine, in case that is relevant)
clang-wtf.zip
The text was updated successfully, but these errors were encountered: