rust/tests/fail/transmute_fat1.rs

14 lines
366 B
Rust
Raw Normal View History

2022-06-03 07:46:22 -05:00
// error-pattern: type validation failed: encountered a pointer
2017-07-12 02:29:18 -05:00
fn main() {
#[cfg(target_pointer_width="64")]
let bad = unsafe {
std::mem::transmute::<&[u8], [u8; 16]>(&[1u8])
2017-07-12 02:29:18 -05:00
};
#[cfg(target_pointer_width="32")]
let bad = unsafe {
std::mem::transmute::<&[u8], [u8; 8]>(&[1u8])
2017-07-12 02:29:18 -05:00
};
2022-06-03 07:46:22 -05:00
let _val = bad[0] + bad[bad.len()-1];
2017-07-12 02:29:18 -05:00
}