1 // We want to control preemption here.
2 //@compile-flags: -Zmiri-preemption-rate=0
4 use std::sync::atomic::Ordering::*;
5 use std::sync::atomic::{AtomicU16, AtomicU32};
6 use std::thread::spawn;
8 fn static_atomic(val: u32) -> &'static AtomicU32 {
9 let ret = Box::leak(Box::new(AtomicU32::new(val)));
13 fn split_u32_ptr(dword: *const u32) -> *const [u16; 2] {
14 unsafe { std::mem::transmute::<*const u32, *const [u16; 2]>(dword) }
17 // Racing mixed size reads may cause two loads to read-from
18 // the same store but observe different values, which doesn't make
19 // sense under the formal model so we forbade this.
21 let x = static_atomic(0);
23 let j1 = spawn(move || {
27 let j2 = spawn(move || {
28 let x_ptr = x as *const AtomicU32 as *const u32;
29 let x_split = split_u32_ptr(x_ptr);
31 let hi = x_split as *const u16 as *const AtomicU16;
32 (*hi).load(Relaxed); //~ ERROR: imperfectly overlapping