2016-07-06 04:19:24 -05:00
|
|
|
fn main() {
|
|
|
|
// miri always gives allocations the worst possible alignment, so a `u8` array is guaranteed
|
|
|
|
// to be at the virtual location 1 (so one byte offset from the ultimate alignemnt location 0)
|
|
|
|
let mut x = [0u8; 20];
|
|
|
|
let x_ptr: *mut u8 = &mut x[0];
|
|
|
|
let y_ptr = x_ptr as *mut u64;
|
|
|
|
unsafe {
|
2020-03-08 17:34:54 -05:00
|
|
|
*y_ptr = 42; //~ ERROR accessing memory with alignment 1, but alignment
|
2016-07-06 04:19:24 -05:00
|
|
|
}
|
|
|
|
panic!("unreachable in miri");
|
|
|
|
}
|