diff options
Diffstat (limited to 'tests/ui/mir/alignment/misaligned_lhs.rs')
-rw-r--r-- | tests/ui/mir/alignment/misaligned_lhs.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/ui/mir/alignment/misaligned_lhs.rs b/tests/ui/mir/alignment/misaligned_lhs.rs new file mode 100644 index 000000000..97644ba8e --- /dev/null +++ b/tests/ui/mir/alignment/misaligned_lhs.rs @@ -0,0 +1,13 @@ +// run-fail +// ignore-wasm32-bare: No panic messages +// ignore-i686-pc-windows-msvc: #112480 +// compile-flags: -C debug-assertions +// error-pattern: misaligned pointer dereference: address must be a multiple of 0x4 but is + +fn main() { + let mut x = [0u32; 2]; + let ptr = x.as_mut_ptr(); + unsafe { + *(ptr.byte_add(1)) = 42; + } +} |