Skip to content

Inline asm! only checked when used #80440

Closed
@phil-opp

Description

@phil-opp

I tried this code:

#![feature(asm)]

fn main() {
    // errors if the following line is uncommented
    // foo()
}

pub fn foo() {
    unsafe {
        asm!("xchgfoobarbaz bx, bx");
    }
}

(playground)

I expected to see this happen: Compilation error because xchgfoobarbaz is not a valid assembly instruction.

Instead, this happened: The code compiles without errors or warnings. A compile error only occurs if the foo() call is uncommented in main.

Meta

Nightly version on playground: 2020-12-22 bb1fbbf

Originally reported by @tomaka in rust-osdev/x86_64#218.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-inline-assemblyArea: Inline assembly (`asm!(…)`)C-bugCategory: This is a bug.F-asm`#![feature(asm)]` (not `llvm_asm`)T-compilerRelevant to the compiler 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