]> git.lizzy.rs Git - rust.git/blob - tests/compile-fail/unaligned_ptr_cast_zst.rs
d52b569175c1dc51a08099582e94388d72775965
[rust.git] / tests / compile-fail / unaligned_ptr_cast_zst.rs
1 fn main() {
2     let x = &2u16;
3     let x = x as *const _ as *const [u32; 0];
4     // This must fail because alignment is violated. Test specifically for loading ZST.
5     let _x = unsafe { *x };
6     //~^ ERROR tried to access memory with alignment 2, but alignment 4 is required
7 }