summaryrefslogtreecommitdiffstats
path: root/src/test/ui/const-generics/issues/issue-61422.rs
blob: 0b9cf40d855545f10f1105a1ca385fced65e327c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// check-pass
use std::mem;

// Neither of the uninits below are currently accepted as not UB, however,
// this code does not run and is merely checking that we do not ICE on this pattern,
// so this is fine.

fn foo<const SIZE: usize>() {
    let arr: [u8; SIZE] = unsafe {
        #[allow(deprecated)]
        let array: [u8; SIZE] = mem::uninitialized();
        array
    };
}

fn bar<const SIZE: usize>() {
    let arr: [u8; SIZE] = unsafe {
        let array: [u8; SIZE] = mem::MaybeUninit::uninit().assume_init();
        array
    };
}


fn main() {}