1 // Validation makes this fail in the wrong place
2 // compile-flags: -Zmiri-disable-validation
4 // Even with intptrcast and without validation, we want to be *sure* to catch bugs
5 // that arise from pointers being insufficiently aligned. The only way to achieve
6 // that is not not let programs exploit integer information for alignment, so here
7 // we test that this is indeed the case.
10 let base_addr = x as *mut _ as usize;
11 let u16_ref = unsafe { if base_addr % 2 == 0 {
12 &mut *(base_addr as *mut u16)
14 &mut *((base_addr+1) as *mut u16)
16 *u16_ref = 2; //~ ERROR tried to access memory with alignment 1, but alignment 2 is required