2021-03-28 06:54:27 -05:00
|
|
|
// run-pass (note: this is spec-UB, but it works for now)
|
|
|
|
// ignore-32bit (needs `usize` to be 8-aligned to reproduce all the errors below)
|
|
|
|
#![allow(dead_code)]
|
|
|
|
// ignore-emscripten weird assertion?
|
|
|
|
|
|
|
|
#[repr(C, packed(4))]
|
|
|
|
struct Foo4C {
|
|
|
|
bar: u8,
|
|
|
|
baz: usize
|
|
|
|
}
|
|
|
|
|
2022-03-27 11:42:19 -05:00
|
|
|
#[warn(unaligned_references)]
|
2021-03-28 06:54:27 -05:00
|
|
|
pub fn main() {
|
|
|
|
let foo = Foo4C { bar: 1, baz: 2 };
|
|
|
|
let brw = &foo.baz; //~WARN reference to packed field is unaligned
|
|
|
|
//~^ previously accepted
|
|
|
|
assert_eq!(*brw, 2);
|
|
|
|
}
|