about summary refs log tree commit diff
path: root/src/tools/miri/tests/fail/const-ub-checks.rs
blob: 004bbe9f5ea3118699ac992b0a4c0bc6c6b0d33c (plain)
1
2
3
4
5
6
7
8
9
const UNALIGNED_READ: () = unsafe {
    let x = &[0u8; 4];
    let ptr = x.as_ptr().cast::<u32>();
    ptr.read(); //~ERROR: accessing memory based on pointer with alignment 1, but alignment 4 is required
};

fn main() {
    let _x = UNALIGNED_READ;
}