You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
I don't think emitting nounwind should be platform dependent.
Note that emitting nounwind might not need to be platform dependent to support what the reference currently says. Apparently, nounwind does not mean "does not unwind", but rather "does not unwind in certain specific ways that are platform dependent". So for MSVC targets, nounwind functions can actually unwind in some ways, and that's ok according to LLVM.
The current documentation of the
extern "C"
ABI in the reference says: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 bylongjmp
).If this is actually the intended behavior we probably should not emit
nounwind
forextern "C"
functions on Windows. That would have fixed rust-lang/rust#48251 in a different way since that would have allowedlongjmp
s from C into Rust. In the LLVM issue different strategies to allowingnounwind
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 3461ff1cc @Centril @nagisa @eddyb
The text was updated successfully, but these errors were encountered: