rust/tests/compile-fail/null_pointer_deref.rs
2022-03-24 10:06:33 -04:00

6 lines
177 B
Rust

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