]> git.lizzy.rs Git - rust.git/blob - src/test/ui/packed/packed-struct-borrow-element-64bit.rs
Rollup merge of #105419 - YC:issue-41731, r=petrochenkov
[rust.git] / src / test / 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 }