2022-05-24 10:49:11 -05:00
|
|
|
#![feature(strict_provenance)]
|
|
|
|
|
|
|
|
// Ensure that a `ptr::invalid` ptr is truly invalid.
|
|
|
|
fn main() {
|
|
|
|
let x = 42;
|
|
|
|
let xptr = &x as *const i32;
|
|
|
|
let xptr_invalid = std::ptr::invalid::<i32>(xptr.expose_addr());
|
2022-07-11 06:44:55 -05:00
|
|
|
let _val = unsafe { *xptr_invalid }; //~ ERROR: is a dangling pointer
|
2022-05-24 10:49:11 -05:00
|
|
|
}
|