Allow pointers in inline assembly const
expressions #132012
Closed
Description
Quoting from tests/ui/asm/const-refs-to-static.rs
@ 31e102c
I tried this code:
use std::arch::{asm, global_asm};
use std::ptr::addr_of;
static FOO: u8 = 42;
#[no_mangle]
fn inline() {
unsafe { asm!("{}", const addr_of!(FOO)) };
}
I expected to see this happen: it should compiles
Instead, this happened: *const u8
is not allowed as an operand to inline assembly.
This would be coming useful and brings us feature-parity with asm(" /* assembly */ " ::"i"(ptr))
from C, where ptr
can be pointer to statics and constants.
Meta
rustc --version --verbose
:
<version>
Backtrace
<backtrace>
Metadata
Assignees
Labels
Area: Inline assembly (`asm!(…)`)Relevant for the Rust-for-Linux projectCategory: A feature request, i.e: not implemented / a PR.Relevant to the compiler team, which will review and decide on the PR/issue.Relevant to the language team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.