2019-09-01 16:30:19 -05:00
|
|
|
// check-pass
|
2019-06-01 05:57:22 -05:00
|
|
|
use std::mem;
|
|
|
|
|
2019-12-21 20:43:13 -06:00
|
|
|
// 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.
|
|
|
|
|
2019-06-01 05:57:22 -05:00
|
|
|
fn foo<const SIZE: usize>() {
|
|
|
|
let arr: [u8; SIZE] = unsafe {
|
2019-07-04 10:24:56 -05:00
|
|
|
#[allow(deprecated)]
|
2019-09-01 16:30:19 -05:00
|
|
|
let array: [u8; SIZE] = mem::uninitialized();
|
2019-06-01 05:57:22 -05:00
|
|
|
array
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2019-12-21 20:43:13 -06:00
|
|
|
fn bar<const SIZE: usize>() {
|
|
|
|
let arr: [u8; SIZE] = unsafe {
|
|
|
|
let array: [u8; SIZE] = mem::MaybeUninit::uninit().assume_init();
|
|
|
|
array
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-06-01 05:57:22 -05:00
|
|
|
fn main() {}
|