]> git.lizzy.rs Git - rust.git/blob - tests/compile-fail/alignment.rs
bac1b92075a76f07bfa8627a43648d566bfafac1
[rust.git] / tests / compile-fail / alignment.rs
1 fn main() {
2     // miri always gives allocations the worst possible alignment, so a `u8` array is guaranteed
3     // to be at the virtual location 1 (so one byte offset from the ultimate alignemnt location 0)
4     let mut x = [0u8; 20];
5     let x_ptr: *mut u8 = &mut x[0];
6     let y_ptr = x_ptr as *mut u64;
7     unsafe {
8         *y_ptr = 42; //~ ERROR accessing memory with alignment 1, but alignment
9     }
10     panic!("unreachable in miri");
11 }