work around rustc optimizations becoming too smart

This commit is contained in:
Ralf Jung 2020-09-07 10:24:04 +02:00
parent 5f1182d04a
commit 210f18d6c7
3 changed files with 5 additions and 3 deletions

2
ci.sh
View File

@ -25,7 +25,7 @@ function run_tests {
./miri test --locked
if ! [ -n "${MIRI_TEST_TARGET+exists}" ]; then
# Only for host architecture: tests with MIR optimizations
# FIXME:only testing level 1 because of <https://github.com/rust-lang/rust/issues/73223>.
# FIXME: only testing level 1 because of <https://github.com/rust-lang/rust/issues/73223>.
MIRI_TEST_FLAGS="-Z mir-opt-level=1" ./miri test --locked
fi
# "miri test" has built the sysroot for us, now this should pass without

View File

@ -1 +1 @@
d2454643e137bde519786ee9e650c455d7ad6f34
e114d6228b948ce056de0bcdec2603c8e89d3727

View File

@ -2,7 +2,9 @@
// Make sure we find these even with many checks disabled.
// compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation
fn dont_optimize<T>(x: T) -> T { x }
fn main() {
let b = unsafe { std::mem::transmute::<u8, bool>(2) };
let _x = b == true; //~ ERROR interpreting an invalid 8-bit value as a bool: 0x02
let _x = b == dont_optimize(true); //~ ERROR interpreting an invalid 8-bit value as a bool: 0x02
}