1 // ignore-windows: Concurrency on Windows is not supported yet.
3 #![feature(core_intrinsics)]
5 use std::sync::atomic::AtomicU32;
6 use std::sync::atomic::Ordering::*;
7 use std::thread::spawn;
9 fn static_atomic(val: u32) -> &'static AtomicU32 {
10 let ret = Box::leak(Box::new(AtomicU32::new(val)));
14 fn split_u32_ptr(dword: *const u32) -> *const [u16; 2] {
15 unsafe { std::mem::transmute::<*const u32, *const [u16; 2]>(dword) }
18 // Racing mixed size reads may cause two loads to read-from
19 // the same store but observe different values, which doesn't make
20 // sense under the formal model so we forbade this.
22 let x = static_atomic(0);
24 let j1 = spawn(move || {
28 let j2 = spawn(move || {
29 let x_ptr = x as *const AtomicU32 as *const u32;
30 let x_split = split_u32_ptr(x_ptr);
32 let hi = &(*x_split)[0] as *const u16;
33 std::intrinsics::atomic_load_relaxed(hi); //~ ERROR: imperfectly overlapping