Invalid operand for asm 'i' inline constraint when writing x86_64 inline assembly

The code below is used to create just fine in April (Rust ~ 1.6 version), but this is no longer there.

#![feature(asm)]

enum MyEnum { One = 1 }

fn main() {
    unsafe {
        asm!("nop" : : "i" (MyEnum::One as isize) : : ); // broken
    }
}

The error message does not indicate any obvious changes that may cause this.

+4
source share
1 answer

The value for the constraint "i"must be a compile-time constant, and you supply it with what is not. If you move the addition to Rust, you can use case as well as constant using restrictions "ri".

Whether something can be permanent for the purpose of the built-in assembler, optimization parameters can influence.

+4

Source: https://habr.com/ru/post/1664481/


All Articles