]> git.lizzy.rs Git - rust.git/blob - src/tools/miri/tests/fail/dangling_pointers/null_pointer_deref_zst.rs
Merge commit 'd822110d3b5625b9dc80ccc442e06fc3cc851d76' into clippyup
[rust.git] / src / tools / miri / tests / fail / dangling_pointers / 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: null pointer is a dangling pointer
7     panic!("this should never print: {:?}", x);
8 }