Does the following code trigger UB?
union Foo { bar: i32, bar2: bool, } fn main() { let foo = unsafe { MaybeUninit::<Foo>::uninit().assume_init() }; } Because foo is never read as bar or bar2 then its data is never realized. Also, is the same true if ::zeroed() instead of ::uninit()?
playground (passes miri)
10 posts - 5 participants


