rust/tests/compile-fail/transmute_fat2.rs

12 lines
318 B
Rust
Raw Normal View History

2017-07-12 02:29:18 -05:00
fn main() {
#[cfg(target_pointer_width="64")]
let bad = unsafe {
std::mem::transmute::<u128, &[u8]>(42)
};
#[cfg(target_pointer_width="32")]
let bad = unsafe {
std::mem::transmute::<u64, &[u8]>(42)
};
2018-10-19 04:50:17 -05:00
bad[0]; //~ ERROR index out of bounds: the len is 0 but the index is 0
2017-07-12 02:29:18 -05:00
}