`naked_asm!` does not accept assembly syntax that is accepted by `asm!`
Open
Nobody has claimed this yet.
A-inline-assembly
A-naked
C-bug
F-naked_functions
T-compiler
T-libs
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
I tried this code:
extern "C" fn foo() {
unsafe {
core::arch::asm!("mov rax, QWORD PTR gs:[60h]");
}
}
#[unsafe(naked)]
extern "C" fn foo2() {
core::arch::naked_asm!("mov rax, QWORD PTR gs:[60h]")
}
I expected to see this happen: Both functions assemble correctly, as the only difference between the assembly statements is naked_asm! being used instead of asm!.
Instead, this happened: Assembly error in foo2:
error: <inline asm>:10:27: unknown token in expression
mov rax, QWORD PTR gs:[60h]
^
Meta
rustc --version --verbose:
rustc 1.92.0-nightly (4645a7988 2025-09-17)
binary: rustc
commit-hash: 4645a7988177c286f61609cc667ecae4c571a2e8
commit-date: 2025-09-17
host: x86_64-pc-windows-msvc
release: 1.92.0-nightly
LLVM version: 21.1.1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the minimal Rust reproducer in the issue and compare how asm! and naked_asm! handle the same assembly string on x86_64-pc-windows-msvc. Trace the compiler or LLVM path responsible for the differing expression parsing. Done means the shown naked_asm! statement assembles successfully without regressing existing behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100