]> git.lizzy.rs Git - rust.git/blobdiff - tests/compile-fail/unaligned_pointers/unaligned_ptr2.rs
forgot to add alignment test loop in one test
[rust.git] / tests / compile-fail / unaligned_pointers / unaligned_ptr2.rs
index f4ed8d47b53f1a70edbe3b85ee9c5e75710d6388..49612e2b8a0964087d7a6f3e1233218fd362fdce 100644 (file)
@@ -2,11 +2,11 @@
 // compile-flags: -Zmiri-disable-validation -Zmiri-disable-stacked-borrows
 
 fn main() {
-    for _ in 0..10 { // Try many times as this might work by chance.
-        let x = [2u32, 3]; // Make it big enough so we don't get an out-of-bounds error.
-        let x = (x.as_ptr() as *const u8).wrapping_offset(3) as *const u32;
-        // This must fail because alignment is violated: the offset is not sufficiently aligned.
-        // Also make the offset not a power of 2, that used to ICE.
-        let _x = unsafe { *x }; //~ ERROR memory with alignment 1, but alignment 4 is required
-    }
+    // No retry needed, this fails reliably.
+
+    let x = [2u32, 3]; // Make it big enough so we don't get an out-of-bounds error.
+    let x = (x.as_ptr() as *const u8).wrapping_offset(3) as *const u32;
+    // This must fail because alignment is violated: the offset is not sufficiently aligned.
+    // Also make the offset not a power of 2, that used to ICE.
+    let _x = unsafe { *x }; //~ERROR memory with alignment 1, but alignment 4 is required
 }