diff --git a/tests/compile-fail/dangling_pointers/dangling_zst_deref.rs b/tests/compile-fail/dangling_pointers/dangling_zst_deref.rs index f1b5149dabb4..01e864213df7 100644 --- a/tests/compile-fail/dangling_pointers/dangling_zst_deref.rs +++ b/tests/compile-fail/dangling_pointers/dangling_zst_deref.rs @@ -1,5 +1,6 @@ // Make sure we find these even with many checks disabled. -// compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation +// Some optimizations remove ZST accesses, thus masking this UB. +// compile-flags: -Zmir-opt-level=0 -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation fn main() { let p = { diff --git a/tests/compile-fail/dangling_pointers/maybe_null_pointer_deref_zst.rs b/tests/compile-fail/dangling_pointers/maybe_null_pointer_deref_zst.rs index d9f5ad4c696e..9db8a7dcba98 100644 --- a/tests/compile-fail/dangling_pointers/maybe_null_pointer_deref_zst.rs +++ b/tests/compile-fail/dangling_pointers/maybe_null_pointer_deref_zst.rs @@ -1,3 +1,6 @@ +// Some optimizations remove ZST accesses, thus masking this UB. +// compile-flags: -Zmir-opt-level=0 + fn main() { // This pointer *could* be NULL so we cannot load from it, not even at ZST let ptr = (&0u8 as *const u8).wrapping_sub(0x800) as *const (); diff --git a/tests/compile-fail/dangling_pointers/maybe_null_pointer_write_zst.rs b/tests/compile-fail/dangling_pointers/maybe_null_pointer_write_zst.rs index ef46a469c3ad..79eff2507ceb 100644 --- a/tests/compile-fail/dangling_pointers/maybe_null_pointer_write_zst.rs +++ b/tests/compile-fail/dangling_pointers/maybe_null_pointer_write_zst.rs @@ -1,3 +1,6 @@ +// Some optimizations remove ZST accesses, thus masking this UB. +// compile-flags: -Zmir-opt-level=0 + fn main() { // This pointer *could* be NULL so we cannot load from it, not even at ZST. // Not using the () type here, as writes of that type do not even have MIR generated. diff --git a/tests/compile-fail/null_pointer_deref_zst.rs b/tests/compile-fail/null_pointer_deref_zst.rs index cfd3a75e3b8c..d0f21a04d364 100644 --- a/tests/compile-fail/null_pointer_deref_zst.rs +++ b/tests/compile-fail/null_pointer_deref_zst.rs @@ -1,3 +1,6 @@ +// Some optimizations remove ZST accesses, thus masking this UB. +// compile-flags: -Zmir-opt-level=0 + fn main() { let x: () = unsafe { *std::ptr::null() }; //~ ERROR memory access failed: 0x0 is not a valid pointer panic!("this should never print: {:?}", x); diff --git a/tests/compile-fail/null_pointer_write_zst.rs b/tests/compile-fail/null_pointer_write_zst.rs index 0f7244ba25cc..1ee1a4b8a303 100644 --- a/tests/compile-fail/null_pointer_write_zst.rs +++ b/tests/compile-fail/null_pointer_write_zst.rs @@ -1,3 +1,6 @@ +// Some optimizations remove ZST accesses, thus masking this UB. +// compile-flags: -Zmir-opt-level=0 + fn main() { // Not using the () type here, as writes of that type do not even have MIR generated. // Also not assigning directly as that's array initialization, not assignment. diff --git a/tests/compile-fail/unaligned_pointers/unaligned_ptr_zst.rs b/tests/compile-fail/unaligned_pointers/unaligned_ptr_zst.rs index a9db5ff7df39..27403c11abc7 100644 --- a/tests/compile-fail/unaligned_pointers/unaligned_ptr_zst.rs +++ b/tests/compile-fail/unaligned_pointers/unaligned_ptr_zst.rs @@ -1,5 +1,6 @@ // This should fail even without validation -// compile-flags: -Zmiri-disable-validation +// Some optimizations remove ZST accesses, thus masking this UB. +// compile-flags: -Zmir-opt-level=0 -Zmiri-disable-validation fn main() { for i in 0..10 { // Try many times as this might work by chance. diff --git a/tests/compile-fail/zst2.rs b/tests/compile-fail/zst2.rs index 907337dcdb2b..a602cb731e40 100644 --- a/tests/compile-fail/zst2.rs +++ b/tests/compile-fail/zst2.rs @@ -1,3 +1,6 @@ +// Some optimizations remove ZST accesses, thus masking this UB. +// compile-flags: -Zmir-opt-level=0 + fn main() { // Not using the () type here, as writes of that type do not even have MIR generated. // Also not assigning directly as that's array initialization, not assignment. diff --git a/tests/compile-fail/zst3.rs b/tests/compile-fail/zst3.rs index c94591174ec5..734c4b8ac4b8 100644 --- a/tests/compile-fail/zst3.rs +++ b/tests/compile-fail/zst3.rs @@ -1,3 +1,6 @@ +// Some optimizations remove ZST accesses, thus masking this UB. +// compile-flags: -Zmir-opt-level=0 + fn main() { // Not using the () type here, as writes of that type do not even have MIR generated. // Also not assigning directly as that's array initialization, not assignment.