-
Couldn't load subscription status.
- Fork 13.9k
Open
Labels
A-inline-assemblyArea: Inline assembly (`asm!(…)`)Area: Inline assembly (`asm!(…)`)A-monomorphizationArea: MonomorphizationArea: MonomorphizationC-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
I tried this code:
#![no_std] #[inline(always)] pub fn checkasm() { unsafe { core::arch::asm!("nonsense"); } } #[unsafe(no_mangle)] fn foo() { // checkasm(); }https://rust.godbolt.org/z/qWYnefq5a
I expected to see this happen: the lib would fail to compile
Instead, this happened: the lib compiles OK. But, if the function is actually called, then it does fail.
It is non-obvious that you can compile a library containing bad assembly if the function is marked inline(always).
See chat on Zulip: https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/inline.28always.29.20caused.20inline.20assembly.20to.20not.20get.20checked/near/541817357
Meta
I've seen this on 1.89 in Godbolt and on my desktop.
saethlin and workingjubilee
Metadata
Metadata
Assignees
Labels
A-inline-assemblyArea: Inline assembly (`asm!(…)`)Area: Inline assembly (`asm!(…)`)A-monomorphizationArea: MonomorphizationArea: MonomorphizationC-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.