rust/tests/ui/consts/const-eval/ub-invalid-values.rs
2024-06-11 13:28:36 +02:00

12 lines
279 B
Rust

const fn bool_cast(ptr: *const bool) { unsafe {
let _val = *ptr as u32; //~ERROR: evaluation of constant value failed
//~^ interpreting an invalid 8-bit value as a bool
}}
const _: () = {
let v = 3_u8;
bool_cast(&v as *const u8 as *const bool);
};
fn main() {}