]> git.lizzy.rs Git - rust.git/blob - src/tools/miri/tests/panic/transmute_fat2.rs
Rollup merge of #102092 - kxxt:patch-1, r=joshtriplett
[rust.git] / src / tools / miri / tests / panic / transmute_fat2.rs
1 fn main() {
2     #[cfg(all(target_endian = "little", target_pointer_width = "64"))]
3     let bad = unsafe { std::mem::transmute::<u128, &[u8]>(42) };
4     #[cfg(all(target_endian = "big", target_pointer_width = "64"))]
5     let bad = unsafe { std::mem::transmute::<u128, &[u8]>(42 << 64) };
6     #[cfg(all(target_endian = "little", target_pointer_width = "32"))]
7     let bad = unsafe { std::mem::transmute::<u64, &[u8]>(42) };
8     // This created a slice with length 0, so the following will fail the bounds check.
9     bad[0];
10 }