rust/tests/compile-fail/reference_to_packed.rs
2017-06-24 11:05:13 -07:00

17 lines
282 B
Rust

#![allow(dead_code, unused_variables)]
#[repr(packed)]
struct Foo {
x: i32,
y: i32,
}
fn main() {
let foo = Foo {
x: 42,
y: 99,
};
let p = &foo.x; //~ ERROR tried to access memory with alignment 1, but alignment 4 is required
let i = *p;
}