Skip to content

Commit

Permalink
Fix explicit cast test
Browse files Browse the repository at this point in the history
  • Loading branch information
pvdrz committed Jul 3, 2019
1 parent 39d383d commit 8dfb278
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions tests/run-pass-noseed/intptrcast.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// compile-flags: -Zmiri-seed=0000000000000000
fn transmute_ptr_to_int<T>(x: *const T) -> usize {
unsafe { std::mem::transmute::<*const T, usize>(x) * 1 }

// This returns a miri pointer at type usize, if the argument is a proper pointer
fn transmute_ptr_to_int<T>(x: *const T) -> usize {
unsafe { std::mem::transmute(x) }
}

fn main() {
// Some casting-to-int with arithmetic.
let x = &42 as *const i32 as usize;
let x = &42 as *const i32 as usize;
let y = x * 2;
assert_eq!(y, x + x);
let z = y as u8 as usize;
Expand Down

0 comments on commit 8dfb278

Please sign in to comment.