rust/tests/pass/static_memory_modification.rs
2022-06-20 23:50:40 -07:00

15 lines
276 B
Rust

use std::sync::atomic::{AtomicUsize, Ordering};
static mut X: usize = 5;
static Y: AtomicUsize = AtomicUsize::new(5);
fn main() {
unsafe {
X = 6;
assert_eq!(X, 6);
}
Y.store(6, Ordering::Relaxed);
assert_eq!(Y.load(Ordering::Relaxed), 6);
}