Skip to content

mem::zeroed/uninit: panic on types that do not permit zero-initialization #66059

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Mar 11, 2020
Prev Previous commit
Next Next commit
clarify a comment in the test
  • Loading branch information
RalfJung committed Feb 29, 2020
commit bfe593e03a0f73ee52ac666be17e963957ef628f
4 changes: 3 additions & 1 deletion src/test/ui/intrinsics/panic-uninitialized-zeroed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,9 @@ fn main() {
let _val = mem::zeroed::<MaybeUninit<NonNull<u32>>>();
let _val = mem::uninitialized::<MaybeUninit<bool>>();

// We don't panic for these just to be conservative. They are UB as of now (2019-11-09).
// These are UB because they have not been officially blessed, but we await the resolution
// of <https://github.com/rust-lang/unsafe-code-guidelines/issues/71> before doing
// anything about that.
let _val = mem::uninitialized::<i32>();
let _val = mem::uninitialized::<*const ()>();
}
Expand Down