Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 34d4928

Browse files
committed
addr no longer exposes :)
1 parent 63625b0 commit 34d4928

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
// compile-flags: -Zmiri-permissive-provenance -Zmiri-disable-stacked-borrows -Zmiri-allow-ptr-int-transmute
1+
// compile-flags: -Zmiri-permissive-provenance -Zmiri-disable-stacked-borrows
2+
#![feature(strict_provenance)]
23

34
fn main() {
45
let x: i32 = 3;
56
let x_ptr = &x as *const i32;
67

7-
// TODO: switch this to addr() once we intrinsify it
8-
let x_usize: usize = unsafe { std::mem::transmute(x_ptr) };
9-
// Cast back a pointer that did *not* get exposed.
10-
let ptr = x_usize as *const i32;
8+
let x_usize: usize = x_ptr.addr();
9+
// Cast back an address that did *not* get exposed.
10+
let ptr = std::ptr::from_exposed_addr::<i32>(x_usize);
1111
assert_eq!(unsafe { *ptr }, 3); //~ ERROR Undefined Behavior: dereferencing pointer failed
1212
}

0 commit comments

Comments
 (0)