Skip to content

Invalid inline assembly is silently discarded #22892

Description

@devyn

Minimal testcase:

#![feature(asm)]

fn main() {
    let byte = 0;
    let port = 0x80;

    unsafe { asm!("out %al, %dx" :: "a" (byte), "d" (port) :: "volatile"); }
}

rustc --version:

rustc 1.0.0-nightly (4db0b3246 2015-02-25) (built 2015-02-26)

rustc output:

$ rustc mintest.rs
$

(i.e., nothing)

Resulting objdump on x86_64-unknown-linux-gnu:

0000000000005070 <_ZN4main20h953519ae653eac04eaaE>:
    5070:       64 48 3b 24 25 70 00    cmp    %fs:0x70,%rsp
    5077:       00 00 
    5079:       77 1a                   ja     5095 <_ZN4main20h953519ae653eac04eaaE+0x25>
    507b:       49 ba 10 00 00 00 00    movabs $0x10,%r10
    5082:       00 00 00 
    5085:       49 bb 00 00 00 00 00    movabs $0x0,%r11
    508c:       00 00 00 
    508f:       e8 80 00 00 00          callq  5114 <__morestack>
    5094:       c3                      retq   
    5095:       48 83 ec 10             sub    $0x10,%rsp
    5099:       c7 44 24 0c 00 00 00    movl   $0x0,0xc(%rsp)
    50a0:       00 
    50a1:       c7 44 24 08 80 00 00    movl   $0x80,0x8(%rsp)
    50a8:       00 
    50a9:       8b 44 24 0c             mov    0xc(%rsp),%eax
    50ad:       8b 4c 24 08             mov    0x8(%rsp),%ecx
    50b1:       89 44 24 04             mov    %eax,0x4(%rsp)
    50b5:       89 0c 24                mov    %ecx,(%rsp)
    50b8:       48 83 c4 10             add    $0x10,%rsp
    50bc:       c3                      retq   
    50bd:       0f 1f 00                nopl   (%rax)

Unless I'm missing something, I should either get an error, or I should see "out %al, %dx" somewhere in there, but instead, absolutely nothing happens.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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. When possible, use a F-* label instead.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions