]> git.lizzy.rs Git - rust.git/blob - src/tools/miri/tests/fail/dangling_pointers/maybe_null_pointer_deref_zst.rs
Rollup merge of #101815 - diegooliveira:master, r=davidtwco
[rust.git] / src / tools / miri / tests / fail / dangling_pointers / maybe_null_pointer_deref_zst.rs
1 // Some optimizations remove ZST accesses, thus masking this UB.
2 //@compile-flags: -Zmir-opt-level=0
3
4 fn main() {
5     // This pointer *could* be NULL so we cannot load from it, not even at ZST
6     let ptr = (&0u8 as *const u8).wrapping_sub(0x800) as *const ();
7     let _x: () = unsafe { *ptr }; //~ ERROR: out-of-bounds
8 }