rust/tests/fail/const-ub-checks.rs
2022-08-13 08:23:28 -04:00

12 lines
237 B
Rust

#![feature(const_ptr_read)]
const UNALIGNED_READ: () = unsafe {
let x = &[0u8; 4];
let ptr = x.as_ptr().cast::<u32>();
ptr.read(); //~ERROR: evaluation of constant value failed
};
fn main() {
let _x = UNALIGNED_READ;
}