Open
Description
Since #118534 projecting a field of an extern type at non-zero offset panics. MIR transformations do not understand this:
$ cat a.rs
#![feature(extern_types)]
extern "C" {
type Opaque;
}
fn main() {
let a = [0u8; 1];
let b: &(u8, Opaque) = unsafe { &*(&a as *const _ as *const (u8, Opaque)) };
let _ = &b.1;
}
$ rustc a.rs -Zmir-opt-level=1 && ./a
$ rustc a.rs -Zmir-opt-level=0 && ./a
thread 'main' panicked at library/core/src/panicking.rs:221:5:
attempted to compute the size or alignment of extern type `Opaque`
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread caused non-unwinding panic. aborting.
Aborted
Metadata
Metadata
Assignees
Labels
Area: MIR optimizationsCategory: This is a bug.`#![feature(extern_types)]`Issue: Correct Rust code lowers to incorrect machine codeIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the opsem teamThis issue requires a nightly compiler in some way.