rust/tests/ui/packed/packed-struct-borrow-element-64bit.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

16 lines
367 B
Rust
Raw Normal View History

2021-03-28 11:54:27 +00:00
//@ 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
}
pub fn main() {
let foo = Foo4C { bar: 1, baz: 2 };
2022-09-30 12:54:30 +00:00
let brw = &foo.baz; //~ERROR reference to packed field is unaligned
2021-03-28 11:54:27 +00:00
assert_eq!(*brw, 2);
}