Is dereferencing a NULL pointer to a ZST considered UB?

⚓ Rust    📅 2025-12-28    👤 surdeus    👁️ 6      

surdeus

Miri on the Rust Playground did not forbid this:

fn main() {
    let null_ptr = std::ptr::null::<()>();

    let value = unsafe {
        *null_ptr
    };

    dbg!(value);
}

1 post - 1 participant

Read full topic

🏷️ Rust_feed