]> git.lizzy.rs Git - rust.git/blob - src/tools/miri/tests/fail/dangling_pointers/null_pointer_deref_zst.rs
Rollup merge of #102082 - andrewpollack:uid-ignore, r=tmandry
[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 }