rust/tests/compile-fail/null_pointer_deref.rs

6 lines
185 B
Rust
Raw Normal View History

fn main() {
let x: i32 = unsafe { *std::ptr::null() }; //~ ERROR constant evaluation error
//~^ NOTE invalid use of NULL pointer
panic!("this should never print: {}", x);
}