]> git.lizzy.rs Git - rust.git/blob - tests/compile-fail/maybe_null_pointer_write_zst.rs
Auto merge of #1308 - RalfJung:miri, r=RalfJung
[rust.git] / tests / compile-fail / maybe_null_pointer_write_zst.rs
1 fn main() {
2     // This pointer *could* be NULL so we cannot load from it, not even at ZST.
3     // Not using the () type here, as writes of that type do not even have MIR generated.
4     // Also not assigning directly as that's array initialization, not assignment.
5     let zst_val = [1u8; 0];
6     let ptr = (&0u8 as *const u8).wrapping_sub(0x800) as *mut [u8; 0];
7     unsafe { *ptr = zst_val; } //~ ERROR outside bounds
8 }