rust/tests/compile-fail/null_pointer_deref.rs
2018-07-15 12:00:02 +02:00

5 lines
172 B
Rust

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