Skip to content

naked_asm! does not accept assembly syntax that is accepted by asm! #147267

@Fulgen301

Description

@Fulgen301

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-inline-assemblyArea: Inline assembly (`asm!(…)`)A-nakedArea: `#[naked]`, prologue and epilogue-free, functions, https://git.io/vAzzSC-bugCategory: This is a bug.F-naked_functions`#![feature(naked_functions)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-libsRelevant to the library team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions