rust/tests/compile-fail/null_pointer_deref.rs

6 lines
177 B
Rust
Raw Normal View History

2021-04-15 03:00:39 -05:00
#[allow(deref_nullptr)]
fn main() {
2022-03-24 09:06:33 -05:00
let x: i32 = unsafe { *std::ptr::null() }; //~ ERROR null pointer is not a valid pointer
panic!("this should never print: {}", x);
}