rust/tests/run-pass/ref-invalid-ptr.rs
2018-10-11 08:59:39 +02:00

10 lines
340 B
Rust

fn main() {
let x = 2usize as *const u32;
// this is not aligned, but we immediately cast it to a raw ptr so that must be okay
let _y = unsafe { &*x as *const u32 };
let x = 0usize as *const u32;
// this is NULL, but we immediately cast it to a raw ptr so that must be okay
let _y = unsafe { &*x as *const u32 };
}