rust/tests/compile-fail/null_pointer_deref.rs

5 lines
177 B
Rust

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