]> git.lizzy.rs Git - rust.git/blob - tests/ui/packed/packed-struct-borrow-element-64bit.rs
Merge commit '1d8491b120223272b13451fc81265aa64f7f4d5b' into sync-from-rustfmt
[rust.git] / tests / ui / packed / packed-struct-borrow-element-64bit.rs
1 // run-pass (note: this is spec-UB, but it works for now)
2 // ignore-32bit (needs `usize` to be 8-aligned to reproduce all the errors below)
3 #![allow(dead_code)]
4 // ignore-emscripten weird assertion?
5
6 #[repr(C, packed(4))]
7 struct Foo4C {
8     bar: u8,
9     baz: usize
10 }
11
12 #[warn(unaligned_references)]
13 pub fn main() {
14     let foo = Foo4C { bar: 1, baz: 2 };
15     let brw = &foo.baz; //~WARN reference to packed field is unaligned
16     //~^ previously accepted
17     assert_eq!(*brw, 2);
18 }