rust/tests/fail/transmute_fat1.rs

14 lines
327 B
Rust
Raw Normal View History

#[cfg(target_pointer_width = "64")]
const N: usize = 16;
#[cfg(target_pointer_width = "32")]
const N: usize = 8;
2017-07-12 02:29:18 -05:00
fn main() {
let bad = unsafe {
std::mem::transmute::<&[u8], [u8; N]>(&[1u8])
2022-06-29 20:31:27 -05:00
//~^ ERROR: constructing invalid value: encountered a pointer
};
let _val = bad[0] + bad[bad.len() - 1];
2017-07-12 02:29:18 -05:00
}