2017-07-12 09:29:18 +02:00
|
|
|
fn main() {
|
2020-08-22 18:07:43 +02:00
|
|
|
#[cfg(all(target_endian="little", target_pointer_width="64"))]
|
2017-07-12 09:29:18 +02:00
|
|
|
let bad = unsafe {
|
|
|
|
std::mem::transmute::<u128, &[u8]>(42)
|
|
|
|
};
|
2020-08-22 18:07:43 +02:00
|
|
|
#[cfg(all(target_endian="big", target_pointer_width="64"))]
|
|
|
|
let bad = unsafe {
|
|
|
|
std::mem::transmute::<u128, &[u8]>(42 << 64)
|
|
|
|
};
|
|
|
|
#[cfg(all(target_endian="little", target_pointer_width="32"))]
|
2017-07-12 09:29:18 +02:00
|
|
|
let bad = unsafe {
|
|
|
|
std::mem::transmute::<u64, &[u8]>(42)
|
|
|
|
};
|
2020-05-03 12:24:40 +02:00
|
|
|
// This created a slice with length 0, so the following will fail the bounds check.
|
2019-11-29 13:18:54 +01:00
|
|
|
bad[0];
|
2017-07-12 09:29:18 +02:00
|
|
|
}
|