Skip to content

Document unwinding ABI extern "C" #672

Open
@gnzlbg

Description

@gnzlbg

The current documentation of the extern "C" ABI in the reference says:

extern "C" -- This is the same as extern fn foo(); whatever the default your C compiler supports.

When it comes to whether C functions can unwind, the C compiler defaults on most platforms is that these cannot unwind. An exception is MSVC, where AFAICT all functions can always unwind (e.g. even C++ noexcept functions are allowed to be unwound by specific exceptions like, e.g., the one thrown by longjmp).

If this is actually the intended behavior we probably should not emit nounwind for extern "C" functions on Windows. That would have fixed rust-lang/rust#48251 in a different way since that would have allowed longjmps from C into Rust. In the LLVM issue different strategies to allowing nounwind there but fixing things at the LLVM level are being discussed: https://bugs.llvm.org/show_bug.cgi?id=36508.

So as written, whether extern "C" functions can unwind is platform dependent. Is this the intended behavior ? If so, we should clarify this. The earliest I can trace this documentation is 3461ff1

cc @Centril @nagisa @eddyb

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions