-
Notifications
You must be signed in to change notification settings - Fork 358
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
4 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
// compile-flags: -Zmiri-permissive-provenance -Zmiri-disable-stacked-borrows -Zmiri-allow-ptr-int-transmute | ||
// compile-flags: -Zmiri-permissive-provenance -Zmiri-disable-stacked-borrows | ||
#![feature(strict_provenance)] | ||
|
||
fn main() { | ||
let x: i32 = 3; | ||
let x_ptr = &x as *const i32; | ||
|
||
// TODO: switch this to addr() once we intrinsify it | ||
let x_usize: usize = unsafe { std::mem::transmute(x_ptr) }; | ||
let x_usize: usize = x_ptr.addr(); | ||
// Cast back a pointer that did *not* get exposed. | ||
let ptr = x_usize as *const i32; | ||
let ptr = std::ptr::from_exposed_addr::<i32>(x_usize); | ||
assert_eq!(unsafe { *ptr }, 3); //~ ERROR Undefined Behavior: dereferencing pointer failed | ||
} |