Thanks to visit codestin.com
Credit goes to github.com

Skip to content

zig c++ does not support exceptions anymore #9591

@Kha

Description

@Kha
$ 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behaviorregressionIt worked in a previous version of Zig, but stopped working.zig ccZig as a drop-in C compiler feature

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions