rust/tests/pass/disable-alignment-check.rs

12 lines
282 B
Rust
Raw Normal View History

2022-07-08 11:08:32 -05:00
//@compile-flags: -Zmiri-disable-alignment-check
2020-04-13 10:51:22 -05:00
fn main() {
let mut x = [0u8; 20];
let x_ptr: *mut u8 = x.as_mut_ptr();
// At least one of these is definitely unaligned.
unsafe {
*(x_ptr as *mut u64) = 42;
*(x_ptr.add(1) as *mut u64) = 42;
}
}