]> git.lizzy.rs Git - rust.git/blob - tests/compile-fail/unaligned_ptr_zst.rs
31f88c838149ef742e4c7b4e9307bcb0cf939137
[rust.git] / tests / compile-fail / unaligned_ptr_zst.rs
1 // This should fail even without validation
2 // compile-flags: -Zmiri-disable-validation
3
4 fn main() {
5     let x = &2u16;
6     let x = x as *const _ as *const [u32; 0];
7     // This must fail because alignment is violated. Test specifically for loading ZST.
8     let _x = unsafe { *x };
9     //~^ ERROR memory with alignment 2, but alignment 4 is required
10 }