Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Ekleog opened this issue Jun 29, 2017 · 3 comments
Closed
Labels
A-inline-assembly Area: inline asm!(..) C-bug Category: This is a bug. requires-nightly This issue requires a nightly compiler in some way.

Comments

@Ekleog
Copy link

Ekleog commented Jun 29, 2017

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

@Mark-Simulacrum Mark-Simulacrum added the A-inline-assembly Area: inline asm!(..) label Jun 30, 2017
@parched
Copy link
Contributor

parched commented Jun 30, 2017

Same underlying issue as #41337 I guess.

@Mark-Simulacrum Mark-Simulacrum added the C-bug Category: This is a bug. label Jul 28, 2017
@Centril Centril added the requires-nightly This issue requires a nightly compiler in some way. label Oct 25, 2019
@eddyb
Copy link
Member

eddyb commented Mar 13, 2020

Fix might be easy, see #41337 (comment).

@Amanieu
Copy link
Member

Amanieu commented May 22, 2020

This issue does not apply to the new asm! (RFC 2850) which has stricter checks on the types that can be used as asm operands.

The legacy llvm_asm! is deprecated and is no longer maintained.

@Amanieu Amanieu closed this as completed May 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-inline-assembly Area: inline asm!(..) C-bug Category: This is a bug. requires-nightly This issue requires a nightly compiler in some way.
Projects
None yet
Development

No branches or pull requests

6 participants