Skip to content

asm!: push offset causes unexpected token! #74558

Open
@toku-sa-n

Description

@toku-sa-n

Code

#![feature(asm)]

fn main() {
    unsafe {
        asm!(
            "
            push offset 1f
            1:
            "
        );
    }
}

Expectation

Compilable as this assembly code follows the syntax of .intel_syntax noprefix.

Actual

The code will not compile, emitting these errors:

error: unexpected token!
 --> src/main.rs:7:13
  |
7 |             push offset 1f
  |             ^
  |
note: instantiated into assembly here
 --> <inline asm>:3:25
  |
3 |             push offset 1f
  |                         ^

error: aborting due to previous error

error: could not compile `rust`.

Other info

See the comments of the question I posted:
https://stackoverflow.com/questions/62989703/push-label-pushs-label-not-the-address-of-label-rust-asm?noredirect=1#62989703

The equivalent code written in GAS compiles with gcc:

    .intel_syntax noprefix

    .globl main

    .section text
main:
    push offset 1f
1:

Meta

rustc --version --verbose:

rustc 1.46.0-nightly (346aec9b0 2020-07-11)
binary: rustc
commit-hash: 346aec9b02f3c74f3fce97fd6bda24709d220e49
commit-date: 2020-07-11
host: x86_64-unknown-linux-gnu
release: 1.46.0-nightly
LLVM version: 10.0

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`)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions