-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Naked functions contain a trailing ret
insn
#32487
Comments
cc @ticki |
ret
insnret
insn
This is weird... |
cc #32408 |
The core::intrinsics::unreachable() we used at the end of every naked function is essentially pointless, as #[naked] implies that intrinsic at the end of the function. rustc currently does not implement that behavior (rust-lang/rust#32487), but it is a bug. On top of that, anything except a single asm!() in naked functions is likely to be disallowed in the future (rust-lang/rust#32490). A nice side effect is that we avoid the core_intrinsics feature, which will be never stabilized, though neither asm nor naked_functions are likely to be stabilized soon.
The core::intrinsics::unreachable() we used at the end of every naked function is essentially pointless, as #[naked] implies that intrinsic at the end of the function. rustc currently does not implement that behavior (rust-lang/rust#32487), but it is a bug. On top of that, anything except a single asm!() in naked functions is likely to be disallowed in the future (rust-lang/rust#32490). A nice side effect is that we avoid the core_intrinsics feature, which will be never stabilized, though neither asm nor naked_functions are likely to be stabilized soon.
@nagisa This is not a bug. You need to use the @steveklabnik @Mark-Simulacrum This can be closed. |
Well, please note that when @nagisa wrote this, there was an entirely different asm implementation. Checking today's nightly, #![feature(naked_functions, asm)]
#[naked]
pub fn naked(){
unsafe {
asm!("ret");
}
} gives
while #![feature(naked_functions, asm)]
#[naked]
pub fn naked(){
unsafe {
asm!("ret", options(noreturn));
}
} gives
It does seem like the new impl has these semantics, and so yes, this isn't a bug. Thanks all! |
results in
note the trailing retq instruction that shouldn’t otherwise be here.
An equivalent function compiled by clang looks like this:
The text was updated successfully, but these errors were encountered: