We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c6b3f68 commit 798dc5aCopy full SHA for 798dc5a
tests/compile-fail/unaligned_pointers/unaligned_ptr4.rs
@@ -0,0 +1,12 @@
1
+// This should fail even without validation or Stacked Borrows.
2
+// compile-flags: -Zmiri-disable-validation -Zmiri-disable-stacked-borrows
3
+
4
+fn main() {
5
+ // Make sure we notice when a u16 is loaded at offset 1 into a u8 allocation.
6
+ // (This would be missed if u8 allocations are *always* at odd addresses.)
7
+ for _ in 0..10 { // Try many times as this might work by chance.
8
+ let x = [0u8; 4];
9
+ let ptr = x.as_ptr().wrapping_offset(1).cast::<u16>();
10
+ let _val = unsafe { *ptr }; //~ERROR but alignment
11
+ }
12
+}
0 commit comments