1 //@compile-flags: -Zmiri-compare-exchange-weak-failure-rate=0.0
2 use std::sync::atomic::{AtomicBool, Ordering::*};
4 // Ensure that compare_exchange_weak never fails.
6 let atomic = AtomicBool::new(false);
9 let cur = atomic.load(Relaxed);
10 // Try (weakly) to flip the flag.
11 if atomic.compare_exchange_weak(cur, !cur, Relaxed, Relaxed).is_err() {
12 // We failed. Avoid panic machinery as that uses atomics/locks.
13 eprintln!("compare_exchange_weak failed");
14 std::process::abort();