From bdcdb605a49d1e543aac88c1b8ff53274fe1b489 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 3 Jul 2017 16:16:05 -0700 Subject: [PATCH] fix test on i686 --- tests/compile-fail/transmute-pair-undef.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/compile-fail/transmute-pair-undef.rs b/tests/compile-fail/transmute-pair-undef.rs index fad51215dd3..acc6098af7e 100644 --- a/tests/compile-fail/transmute-pair-undef.rs +++ b/tests/compile-fail/transmute-pair-undef.rs @@ -1,17 +1,20 @@ #![feature(core_intrinsics)] +use std::mem; + fn main() { let x: Option> = unsafe { let z = std::intrinsics::add_with_overflow(0usize, 0usize); std::mem::transmute::<(usize, bool), Option>>(z) }; let y = &x; - // Now read this bytewise. There should be 9 def bytes followed by 7 undef bytes (the padding after the bool) in there. + // Now read this bytewise. There should be (ptr_size+1) def bytes followed by (ptr_size-1) undef bytes (the padding after the bool) in there. let z : *const u8 = y as *const _ as *const _; - for i in 0..9 { + let first_undef = mem::size_of::() as isize + 1; + for i in 0..first_undef { let byte = unsafe { *z.offset(i) }; assert_eq!(byte, 0); } - let v = unsafe { *z.offset(9) }; + let v = unsafe { *z.offset(first_undef) }; if v == 0 {} //~ ERROR attempted to read undefined bytes }