2022-07-08 11:08:32 -05:00
|
|
|
//@compile-flags: -Zmiri-permissive-provenance
|
2022-06-03 07:47:00 -05:00
|
|
|
#![feature(strict_provenance)]
|
2022-05-22 15:22:05 -05:00
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let x: i32 = 3;
|
|
|
|
let x_ptr = &x as *const i32;
|
|
|
|
|
2022-06-03 07:47:00 -05:00
|
|
|
let x_usize: usize = x_ptr.addr();
|
|
|
|
// Cast back an address that did *not* get exposed.
|
|
|
|
let ptr = std::ptr::from_exposed_addr::<i32>(x_usize);
|
2022-07-13 17:59:33 -05:00
|
|
|
assert_eq!(unsafe { *ptr }, 3); //~ ERROR: is a dangling pointer
|
2022-05-22 15:22:05 -05:00
|
|
|
}
|