rust/tests/compile-fail/wild_pointer_deref.rs

6 lines
187 B
Rust
Raw Normal View History

fn main() {
let p = 42 as *const i32;
let x = unsafe { *p }; //~ ERROR: attempted to interpret some raw bytes as a pointer address
panic!("this should never print: {}", x);
}