blob: 005ec5f9dfcb4ad55f1607de1b2ea39c06240f7a [file] [edit]
// FIXME(static_mut_refs): use raw pointers instead of references
#![allow(static_mut_refs)]
use std::ptr::addr_of;
static mut FOO: i32 = 42;
static BAR: Foo = Foo(addr_of!(FOO));
#[allow(dead_code)]
struct Foo(*const i32);
unsafe impl Sync for Foo {}
fn main() {
unsafe {
assert_eq!(*BAR.0, 42);
FOO = 5;
assert_eq!(FOO, 5);
assert_eq!(*BAR.0, 5);
}
}