File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change 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) ]
2
3
3
4
fn main ( ) {
4
5
let x: i32 = 3 ;
5
6
let x_ptr = & x as * const i32 ;
6
7
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) ;
11
11
assert_eq ! ( unsafe { * ptr } , 3 ) ; //~ ERROR Undefined Behavior: dereferencing pointer failed
12
12
}
You can’t perform that action at this time.
0 commit comments