Description
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 longjmp
s 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