mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
check that store/load rountrip initializes all bytes
This commit is contained in:
@@ -1022,8 +1022,12 @@ macro_rules! wide_store_load_roundtrip {
|
||||
($elem_ty:ty, $len:expr, $vec_ty:ty, $store:expr, $load:expr) => {
|
||||
let vals: [$elem_ty; $len] = crate::array::from_fn(|i| i as $elem_ty);
|
||||
let a: $vec_ty = transmute(vals);
|
||||
let mut tmp = [0 as $elem_ty; $len];
|
||||
let mut tmp = core::mem::MaybeUninit::<[$elem_ty; $len]>::uninit();
|
||||
$store(tmp.as_mut_ptr().cast(), a);
|
||||
|
||||
// With Miri this will check that all elements were initialized.
|
||||
let tmp = tmp.assume_init();
|
||||
|
||||
let r: $vec_ty = $load(tmp.as_ptr().cast());
|
||||
let out: [$elem_ty; $len] = transmute(r);
|
||||
assert_eq!(out, vals);
|
||||
|
||||
Reference in New Issue
Block a user