Skip to content

"argument never used" in new asm! syntax #72965

Closed
@cesarb

Description

@cesarb

When trying to use the new asm! syntax to implement something similar to std::hint::black_box, it fails with an "argument never used" error. For example (https://godbolt.org/z/mG9AMg):

#![feature(asm)]

pub fn black_box(dummy: i32) -> i32 {
    unsafe {
        asm!("", in(reg) &dummy, options(nostack));
        dummy
    }
}
error: argument never used

 --> <source>:5:18

  |

5 |         asm!("", in(reg) &dummy, options(nostack));

  |                  ^^^^^^^^^^^^^^ argument never used


error: aborting due to previous error


Compiler returned: 1

This makes it impossible to use the new asm! syntax in one of my crates (cesarb/clear_on_drop@43cd2be with CI output at https://travis-ci.org/github/cesarb/clear_on_drop/jobs/694467164).

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`)T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.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