Skip to content

“error: invalid operand for inline asm constraint 'i'” with enum members #42974

Closed
@Ekleog

Description

@Ekleog

Hello,

It looks like in some cases (ie. not enough optimizations turned on), enum members cannot be used as 'i' operands for inline assembly:

#![feature(asm)]

#[repr(usize)]
enum Foo {
    Bar = 1,
}

fn main() {
    unsafe {
        asm!("" :: "i" (9isize), "i" (Foo::Bar));
    }
}

http://play.integer32.com/?gist=befc6872b583ffaa1609f081b7536b50&version=nightly

Given this is (with macros, maybe?) the only use I can think of 'i' operands, I think it is reasonable to say the 'i' operand is currently broken.

This would be solved by even the slightest level of constant folding, so I think even in debug mode it should actually constant fold to something that builds, and not have successful compilation be dependent of the specific compiler version and flags used (as is currently the case).

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-inline-assemblyArea: Inline assembly (`asm!(…)`)C-bugCategory: This is a bug.requires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions