Closed
Description
I tried this code:
union U {
a: &'static i32,
b: usize,
}
fn foo(U { a }: U) {
dbg!(*a);
}
fn main() {
foo(U { b: 0 });
}
I expected to see this happen: rustc rejecting this code. We are transmuting arbitrary types without unsafe, this is clearly unsound.
Instead, this happened: rustc accepted this code, and it SIGSEGVs at runtime.
Metadata
Metadata
Assignees
Labels
Category: This is a bug.Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessCritical priorityRelevant to the compiler team, which will review and decide on the PR/issue.Performance or correctness regression from one stable version to another.