rust/tests/fail/dangling_pointers/deref-invalid-ptr.rs

8 lines
243 B
Rust
Raw Normal View History

// This should fail even without validation.
// compile-flags: -Zmiri-disable-validation -Zmiri-permissive-provenance
fn main() {
2020-04-11 02:30:13 -05:00
let x = 16usize as *const u32;
2022-07-05 17:16:20 -05:00
let _y = unsafe { &*x as *const u32 }; //~ ERROR is a dangling pointer
}