]> git.lizzy.rs Git - rust.git/blob - tests/compile-fail/unaligned_pointers/atomic_unaligned.rs
organize compile-fail tests in folders
[rust.git] / tests / compile-fail / unaligned_pointers / atomic_unaligned.rs
1 #![feature(core_intrinsics)]
2
3 fn main() {
4     // Do a 4-aligned u64 atomic access. That should be UB on all platforms,
5     // even if u64 only has alignment 4.
6     let z = [0u32; 2];
7     let zptr = &z as *const _ as *const u64;
8     unsafe {
9         ::std::intrinsics::atomic_load(zptr);
10         //~^ ERROR accessing memory with alignment 4, but alignment 8 is required
11     }
12 }