]> git.lizzy.rs Git - rust.git/blob - src/tools/miri/tests/fail/concurrency/read_only_atomic_cmpxchg.rs
Auto merge of #101030 - woppopo:const_location, r=scottmcm
[rust.git] / src / tools / miri / tests / fail / concurrency / read_only_atomic_cmpxchg.rs
1 // Should not rely on the aliasing model for its failure.
2 //@compile-flags: -Zmiri-disable-stacked-borrows
3
4 use std::sync::atomic::{AtomicI32, Ordering};
5
6 fn main() {
7     static X: i32 = 0;
8     let x = &X as *const i32 as *const AtomicI32;
9     let x = unsafe { &*x };
10     x.compare_exchange(1, 2, Ordering::Relaxed, Ordering::Relaxed).unwrap_err(); //~ERROR: atomic operations cannot be performed on read-only memory
11 }