rust-lang / rust-lang/rust

Incorrect reporting of asm labels in Nightly

Open
#128,659 8 comments 0 reactions 1 assignee View on GitHub

@asquared31415 is already working on this.

Since Aug 5, 2024.

A-diagnostics A-lints C-bug D-imprecise-spans L-binary_asm_labels T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.