1 // We want to control preemption here.
2 //@compile-flags: -Zmiri-preemption-rate=0
3 //@ignore-windows: Concurrency on Windows is not supported yet.
5 #![feature(core_intrinsics)]
7 use std::sync::atomic::AtomicU32;
8 use std::sync::atomic::Ordering::*;
9 use std::thread::spawn;
11 fn static_atomic(val: u32) -> &'static AtomicU32 {
12 let ret = Box::leak(Box::new(AtomicU32::new(val)));
16 fn split_u32_ptr(dword: *const u32) -> *const [u16; 2] {
17 unsafe { std::mem::transmute::<*const u32, *const [u16; 2]>(dword) }
20 // Racing mixed size reads may cause two loads to read-from
21 // the same store but observe different values, which doesn't make
22 // sense under the formal model so we forbade this.
24 let x = static_atomic(0);
26 let j1 = spawn(move || {
30 let j2 = spawn(move || {
31 let x_ptr = x as *const AtomicU32 as *const u32;
32 let x_split = split_u32_ptr(x_ptr);
34 let hi = &(*x_split)[0] as *const u16;
35 std::intrinsics::atomic_load_relaxed(hi); //~ ERROR: imperfectly overlapping