1 // We want to control preemption here.
2 //@compile-flags: -Zmiri-preemption-rate=0
4 use std::sync::atomic::AtomicUsize;
5 use std::sync::atomic::Ordering;
6 use std::thread::spawn;
9 struct EvilSend<T>(pub T);
11 unsafe impl<T> Send for EvilSend<T> {}
12 unsafe impl<T> Sync for EvilSend<T> {}
15 let mut a = AtomicUsize::new(0);
16 let b = &mut a as *mut AtomicUsize;
19 let j1 = spawn(move || {
20 let atomic_ref = &mut *c.0;
21 atomic_ref.load(Ordering::SeqCst)
24 let j2 = spawn(move || {
25 let atomic_ref = &mut *c.0;
26 *atomic_ref.get_mut() = 32; //~ ERROR: Data race detected between Write on thread `<unnamed>` and Atomic Load on thread `<unnamed>`