summary refs log tree commit diff
path: root/src/test/ui/packed/packed-struct-borrow-element-64bit.rs
blob: ad932fdcd01c47fe5d132bcaa3ff06d775cb1b80 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// 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
}

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);
}