rust/tests/compile-fail/null_pointer_deref.rs

5 lines
177 B
Rust
Raw Normal View History

fn main() {
2017-06-19 03:58:59 -05:00
let x: i32 = unsafe { *std::ptr::null() }; //~ ERROR: a memory access tried to interpret some bytes as a pointer
panic!("this should never print: {}", x);
}