Skip to content
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

Open
themightyoarfish opened this issue May 14, 2024 · 1 comment

Comments

@themightyoarfish
Copy link

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)

clang-wtf.zip

@github-actions github-actions bot added the clang Clang issues not falling into any other category label May 14, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented May 14, 2024

@llvm/issue-subscribers-clang-codegen

Author: Rasmus (themightyoarfish)

# 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)

clang-wtf.zip

@EugeneZelenko EugeneZelenko removed the clang Clang issues not falling into any other category label May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants