]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/issue-63952.rs
35cbc7003f095183119ed320c2289901efa82ac3
[rust.git] / src / test / ui / consts / issue-63952.rs
1 // Regression test for #63952, shouldn't hang.
2
3 use std::usize;
4
5 #[repr(C)]
6 #[derive(Copy, Clone)]
7 struct SliceRepr {
8     ptr: *const u8,
9     len: usize,
10 }
11
12 union SliceTransmute {
13     repr: SliceRepr,
14     slice: &'static [u8],
15 }
16
17 // bad slice: length too big to even exist anywhere
18 const SLICE_WAY_TOO_LONG: &[u8] = unsafe { //~ ERROR: it is undefined behavior to use this value
19     SliceTransmute {
20         repr: SliceRepr {
21             ptr: &42,
22             len: usize::MAX,
23         },
24     }
25     .slice
26 };
27
28 fn main() {}