Skip to content

inline asm jmp 'invalid operand for instruction' #48797

Closed
@aasosaa

Description

@aasosaa

Rust nightly version 2018-02-11 broke some inline assembly in code that previously worked.
Specifically, the jmp instruction on x86_64 doesn't work as it has before.

A minimum example to reproduce is that


fn foo(bytes: &[u8]) -> u32 {
    let result: u32;
    unsafe {
        asm!(
            "
           1:
	      jmp 1b

           "
            : "={ax}"(result)                         // Output register
            : "r"(bytes.as_ptr()), "r"(bytes.len())   // Input registers
            : "rax"                                        // Clobbered registers
            : "intel", "volatile"                     // Options (intel syntax, don't optimize out)
        );
    }
    result
}

now fails to compile with error:
error: <inline asm>:5:2: error: invalid operand for instruction jmp 1b
The code snippet above compiles with rust-nightly-x86_64-unknown-linux-gnu nightly 2018-02-10 and earlier, but returns an error on nightly 2018-02-11 and beyond. I tried looking through the commits that happened that day but couldn't find the exact source of the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-inline-assemblyArea: Inline assembly (`asm!(…)`)C-bugCategory: This is a bug.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