]> git.lizzy.rs Git - rust.git/blob - src/tools/miri/tests/fail/concurrency/read_only_atomic_load.rs
Auto merge of #102573 - RalfJung:mirisync, r=oli-obk
[rust.git] / src / tools / miri / tests / fail / concurrency / read_only_atomic_load.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     // Some targets can implement atomic loads via compare_exchange, so we cannot allow them on
11     // read-only memory.
12     x.load(Ordering::Relaxed); //~ERROR: atomic operations cannot be performed on read-only memory
13 }