rust/tests/ui/stdlib-unit-tests/volatile-fat-ptr.rs
2024-02-16 20:02:50 +00:00

16 lines
317 B
Rust

//@ run-pass
#![allow(stable_features)]
#![feature(volatile)]
use std::ptr::{read_volatile, write_volatile};
fn main() {
let mut x: &'static str = "test";
unsafe {
let a = read_volatile(&x);
assert_eq!(a, "test");
write_volatile(&mut x, "foo");
assert_eq!(x, "foo");
}
}