]> git.lizzy.rs Git - rust.git/blob - tests/compile-fail/null_pointer_deref_zst.rs
04617c58f3cefd9b71c4a362eb9cea4f5f5f3d44
[rust.git] / tests / compile-fail / null_pointer_deref_zst.rs
1 // Some optimizations remove ZST accesses, thus masking this UB.
2 // compile-flags: -Zmir-opt-level=0
3
4 #[allow(deref_nullptr)]
5 fn main() {
6     let x: () = unsafe { *std::ptr::null() }; //~ ERROR dereferencing pointer failed: 0x0 is not a valid pointer
7     panic!("this should never print: {:?}", x);
8 }