Merge pull request #460 from RalfJung/static-mut

Test mutating a non-mut static with interior mutability
This commit is contained in:
Ralf Jung 2018-09-24 22:57:59 +02:00 committed by GitHub
commit 7433c6fc8f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,8 +1,14 @@
use std::sync::atomic::{Ordering, AtomicUsize};
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);
}