Skip to content

Incorrect reporting of asm labels in Nightly #128659

Open
@corigan01

Description

@corigan01

Updating from 1.80.x-nightly to 1.82.x-nightly introduced a new compiler error in one of my inline assembly blocks falsely reporting that an int 0x13 shouldn't include numerical labels.

I tried this code:

    pub fn read(&self, disk: u16) {
        let packet_address = self as *const Self as u16;
        let status: u16;

        unsafe {
            core::arch::asm!("
                push si
                mov si, {packet:x}
                mov ax, 0x4200
                int 0x13
                jc 1f
                mov {status:x}, 0
                jmp 2f
                1:
                mov {status:x}, 1
                2:
                pop si
            ",
                in("dx") disk,
                packet = in(reg) packet_address,
                status = out(reg) status,
            );
        };

        // If the interrupt failed, we want to abort and tell the user
        if status == 1 {
            fail(b'D');
        }
    }

Compiler output:

error: avoid using labels containing only the digits `0` and `1` in inline assembly
  --> bootloader/stage-bootsector/src/disk.rs:38:23
   |
38 |                   int 0x13
   |  _______________________^
39 | |                 jc 1f
40 | |                 mov {status:x}, 0
   | |___________________________^ use a different label that doesn't start with `0` or `1`
   |
   = help: start numbering with `2` instead
   = note: an LLVM bug makes these labels ambiguous with a binary literal number on x86
   = note: see <https://github.com/llvm/llvm-project/issues/99547> for more information
   = note: `#[deny(binary_asm_labels)]` on by default

Meta

rustc --version --verbose:

rustc 1.82.0-nightly (64ebd39da 2024-08-03)

No backtrace was provided even when setting RUST_BACKTRACE=1

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.D-imprecise-spansDiagnostics: spans don't point to exactly the erroneous codeL-binary_asm_labelsLint: LLVM parses labels like 0, 1, 10, 11, etc. oddlyT-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