We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2d24b1b commit 76640ffCopy full SHA for 76640ff
tests/fail/provenance/ptr_int_unexposed.rs
@@ -1,12 +1,12 @@
1
-// compile-flags: -Zmiri-permissive-provenance -Zmiri-disable-stacked-borrows -Zmiri-allow-ptr-int-transmute
+// compile-flags: -Zmiri-permissive-provenance -Zmiri-disable-stacked-borrows
2
+#![feature(strict_provenance)]
3
4
fn main() {
5
let x: i32 = 3;
6
let x_ptr = &x as *const i32;
7
- // TODO: switch this to addr() once we intrinsify it
8
- let x_usize: usize = unsafe { std::mem::transmute(x_ptr) };
+ let x_usize: usize = x_ptr.addr();
9
// Cast back a pointer that did *not* get exposed.
10
- let ptr = x_usize as *const i32;
+ let ptr = std::ptr::from_exposed_addr::<i32>(x_usize);
11
assert_eq!(unsafe { *ptr }, 3); //~ ERROR Undefined Behavior: dereferencing pointer failed
12
}
0 commit comments