about summary refs log tree commit diff
path: root/tests/ui/mir/alignment/borrow_misaligned_field_projection.rs
blob: 6ba895f172d9ea8397762effaf82355012e6280c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//@ run-crash
//@ ignore-i686-pc-windows-msvc: #112480
//@ compile-flags: -C debug-assertions
//@ error-pattern: misaligned pointer dereference: address must be a multiple of 0x4 but is

struct Misalignment {
    a: u32,
}

fn main() {
    let mut items: [Misalignment; 2] = [Misalignment { a: 0 }, Misalignment { a: 1 }];
    unsafe {
        let ptr: *const Misalignment = items.as_ptr().byte_add(1);
        let _ptr: &u32 = unsafe { &(*ptr).a };
    }
}