Files
rust/compiler/rustc_codegen_gcc/tests/run/volatile.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

28 lines
492 B
Rust
Raw Normal View History

// Compiler:
//
// Run-time:
// status: 0
use std::mem::MaybeUninit;
2025-07-16 08:44:15 -04:00
#[allow(dead_code)]
#[derive(Debug)]
struct Struct {
pointer: *const (),
func: unsafe fn(*const ()),
}
2025-07-16 08:44:15 -04:00
fn func(_ptr: *const ()) {
}
fn main() {
let mut x = MaybeUninit::<&Struct>::uninit();
x.write(&Struct {
pointer: std::ptr::null(),
func,
});
let x = unsafe { x.assume_init() };
let value = unsafe { (x as *const Struct).read_volatile() };
println!("{:?}", value);
}