2017-02-07 12:20:16 -06:00
|
|
|
static mut FOO: i32 = 42;
|
|
|
|
static BAR: Foo = Foo(unsafe { &FOO as *const _} );
|
|
|
|
|
2020-04-16 02:25:12 -05:00
|
|
|
#[allow(dead_code)]
|
2017-02-07 12:20:16 -06:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|