]> git.lizzy.rs Git - rust.git/blob - src/tools/miri/tests/fail/unaligned_pointers/reference_to_packed.rs
a807200771d62c087c51e9035a8fa5d50bc30f31
[rust.git] / src / tools / miri / tests / fail / unaligned_pointers / reference_to_packed.rs
1 // This should fail even without validation/SB
2 //@compile-flags: -Zmiri-disable-validation -Zmiri-disable-stacked-borrows
3
4 #![allow(dead_code, unused_variables, unaligned_references)]
5
6 #[repr(packed)]
7 struct Foo {
8     x: i32,
9     y: i32,
10 }
11
12 fn main() {
13     // Try many times as this might work by chance.
14     for _ in 0..20 {
15         let foo = Foo { x: 42, y: 99 };
16         let p = &foo.x;
17         let i = *p; //~ERROR: alignment 4 is required
18     }
19 }