about summary refs log tree commit diff
path: root/tests/ui/mir/alignment/borrow_aligned_field_projection.rs
blob: d3717db77c78d0bf3be51d558cc76fd60d253c22 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//@ run-pass
//@ compile-flags: -C debug-assertions

#[repr(align(8))]
struct Misalignment {
    a: u8,
}

fn main() {
    let mem = 0u64;
    let ptr = &mem as *const u64 as *const Misalignment;
    unsafe {
        let ptr = ptr.byte_add(1);
        let _ref: &u8 = &(*ptr).a;
    }
}