Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

zig c++ does not support exceptions anymore #9591

Closed
Kha opened this issue Aug 19, 2021 · 0 comments · Fixed by #9662
Closed

zig c++ does not support exceptions anymore #9591

Kha opened this issue Aug 19, 2021 · 0 comments · Fixed by #9662
Labels
bug Observed behavior contradicts documented or intended behavior regression It worked in a previous version of Zig, but stopped working. zig cc Zig as a drop-in C compiler feature
Milestone

Comments

@Kha
Copy link
Contributor

Kha commented Aug 19, 2021

$ cat main.cpp
#include <iostream>
#include <exception>

int main() {
  try {
    throw std::exception();
  } catch (std::exception &) {
    std::cerr << "yikes";
  }
  return 0;
}

$ ~/Downloads/zig-linux-x86_64-0.8.0/zig c++ main.cpp && ./a.out
yikes

$ ~/Downloads/zig-linux-x86_64-0.9.0-dev.804+4c9d41730/zig c++ main.cpp && ./a.out
libc++abi: terminating with uncaught exception of type std::exception: std::exception
[5]    2340536 IOT instruction (core dumped)  ./a.out

Plugging the 0.8.0 libunwind.a into the 0.9.0-dev linker command makes it work, so perhaps something similar to https://reviews.llvm.org/D71117? Though that one is about ARM, while I'm on x86_64-linux-gnu.

@andrewrk andrewrk added this to the 0.9.0 milestone Aug 20, 2021
@andrewrk andrewrk added bug Observed behavior contradicts documented or intended behavior regression It worked in a previous version of Zig, but stopped working. zig cc Zig as a drop-in C compiler feature labels Aug 20, 2021
Kha added a commit to Kha/zig that referenced this issue Aug 31, 2021
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Observed behavior contradicts documented or intended behavior regression It worked in a previous version of Zig, but stopped working. zig cc Zig as a drop-in C compiler feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants