From 0b3dba8e702fa7f4a0135098dfe77c98db45490a Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Tue, 16 Feb 2021 09:51:53 +0100 Subject: [PATCH 1/2] rustup and temporarily disable broken tests --- rust-version | 2 +- tests/compile-fail/validity/execute_memory.rs | 1 + tests/compile-fail/validity/invalid_fnptr_uninit.rs | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/rust-version b/rust-version index 26199e0b483..0c82a59c6d1 100644 --- a/rust-version +++ b/rust-version @@ -1 +1 @@ -bb587b1a1737738658d2eaecd4c8c1cab555257a +42a4673fbd40b09a99d057eaa9b3e5579b54c184 diff --git a/tests/compile-fail/validity/execute_memory.rs b/tests/compile-fail/validity/execute_memory.rs index 5230e7fdf52..4be80fe39d0 100644 --- a/tests/compile-fail/validity/execute_memory.rs +++ b/tests/compile-fail/validity/execute_memory.rs @@ -1,3 +1,4 @@ +// ignore-test FIXME (Miri issue #1711) #![feature(box_syntax)] fn main() { diff --git a/tests/compile-fail/validity/invalid_fnptr_uninit.rs b/tests/compile-fail/validity/invalid_fnptr_uninit.rs index dbd6711dc65..ab0e870b420 100644 --- a/tests/compile-fail/validity/invalid_fnptr_uninit.rs +++ b/tests/compile-fail/validity/invalid_fnptr_uninit.rs @@ -1,3 +1,4 @@ +// ignore-test FIXME (Miri issue #1711) #![allow(invalid_value)] union MyUninit { From 4c867feeb637e0172f4c72a3732f9beb5e4f922d Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Tue, 16 Feb 2021 09:55:44 +0100 Subject: [PATCH 2/2] add test by @eddyb --- .../branchless-select-i128-pointer.rs | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 tests/compile-fail/branchless-select-i128-pointer.rs diff --git a/tests/compile-fail/branchless-select-i128-pointer.rs b/tests/compile-fail/branchless-select-i128-pointer.rs new file mode 100644 index 00000000000..61fd57f8f05 --- /dev/null +++ b/tests/compile-fail/branchless-select-i128-pointer.rs @@ -0,0 +1,20 @@ +use std::mem::transmute; + +#[cfg(target_pointer_width = "32")] +type TwoPtrs = i64; +#[cfg(target_pointer_width = "64")] +type TwoPtrs = i128; + +fn main() { + for &my_bool in &[true, false] { + let mask = -(my_bool as TwoPtrs); // false -> 0, true -> -1 aka !0 + // This is branchless code to select one or the other pointer. + // For now, Miri brafs on it, but if this code ever passes we better make sure it behaves correctly. + let val = unsafe { + transmute::<_, &str>( + !mask & transmute::<_, TwoPtrs>("false !") | mask & transmute::<_, TwoPtrs>("true !"), //~ERROR encountered (potentially part of) a pointer, but expected plain (non-pointer) bytes + ) + }; + println!("{}", val); + } +}