diff options
Diffstat (limited to 'tests/ui/packed/packed-struct-borrow-element-64bit.rs')
-rw-r--r-- | tests/ui/packed/packed-struct-borrow-element-64bit.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/ui/packed/packed-struct-borrow-element-64bit.rs b/tests/ui/packed/packed-struct-borrow-element-64bit.rs new file mode 100644 index 000000000..00bddfe40 --- /dev/null +++ b/tests/ui/packed/packed-struct-borrow-element-64bit.rs @@ -0,0 +1,18 @@ +// 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 +} + +#[warn(unaligned_references)] +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); +} |