rust/tests/compile-fail/null_pointer_deref.rs
2021-05-08 15:33:27 +08:00

6 lines
196 B
Rust

#[allow(deref_nullptr)]
fn main() {
let x: i32 = unsafe { *std::ptr::null() }; //~ ERROR null pointer is not a valid pointer for this operation
panic!("this should never print: {}", x);
}