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