about summary refs log tree commit diff
path: root/src/tools/miri/tests/fail/concurrency/read_only_atomic_cmpxchg.rs
blob: 88c73d14ef72b8382d9807c0b8e0081151529c2c (plain)
1
2
3
4
5
6
7
8
9
10
11
// Should not rely on the aliasing model for its failure.
//@compile-flags: -Zmiri-disable-stacked-borrows

use std::sync::atomic::{AtomicI32, Ordering};

fn main() {
    static X: i32 = 0;
    let x = &X as *const i32 as *const AtomicI32;
    let x = unsafe { &*x };
    x.compare_exchange(1, 2, Ordering::Relaxed, Ordering::Relaxed).unwrap_err(); //~ERROR: cannot be performed on read-only memory
}