Fix explicit cast test

This commit is contained in:
Christian Poveda 2019-07-03 13:42:01 -05:00
parent 39d383d9e7
commit 8dfb278ac5

View file

@ -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;