Add example showing UB for uninit Copy types in MaybeUninit::assume_init docs#153030
Add example showing UB for uninit Copy types in MaybeUninit::assume_init docs#153030bp7968h wants to merge 1 commit intorust-lang:mainfrom
Conversation
|
r? @joboet rustbot has assigned @joboet. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
234ebdc to
82e33d1
Compare
| /// // `x` had not been initialized yet, so this last line caused undefined behavior. ⚠️ | ||
| /// ``` | ||
| /// | ||
| /// This also applies to simple types that can hold any bit pattern, like integers, boolean and so on. |
There was a problem hiding this comment.
Booleans cannot hold any bit pattern.
There was a problem hiding this comment.
Oh sorry my bad, a single bit, will amend that, any other improvements needed?
|
r? @RalfJung |
|
|
This PR adds an explicit example and explanation showing that calling
assume_init()on uninitialized memory is undefined behavior even for simple types like integers that can hold any bit pattern.Following up on the discussion in #150689 - waited for @Sekar-C-Mca to respond as suggested by @RalfJung.
Closes #150689