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.