Open
Description
According to rust-lang/rust#78123 (comment) and the Reference, producing an &
-reference (not sure about raw pointers) to an invalid value is instant UB:
Unlike C, Undefined Behavior is pretty limited in scope in Rust. All the core language cares about is preventing the following things:
[...]
a reference/Box
that is dangling, unaligned, or points to an invalid value.
For example, if I understand correctly, this program has UB, but Miri does not report any errors:
enum Void {}
fn main() {
let _x: &Void = unsafe { std::mem::transmute(&()) };
}