mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
Rollup merge of #82837 - RalfJung:maybe-uninit, r=dtolnay
tweak MaybeUninit docs Explain what "(no) fixed value" means.
This commit is contained in:
commit
6220e00ea9
@ -39,10 +39,11 @@ use crate::ptr;
|
|||||||
/// let b: bool = unsafe { MaybeUninit::uninit().assume_init() }; // undefined behavior! ⚠️
|
/// let b: bool = unsafe { MaybeUninit::uninit().assume_init() }; // undefined behavior! ⚠️
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// Moreover, uninitialized memory is special in that the compiler knows that
|
/// Moreover, uninitialized memory is special in that it does not have a fixed value ("fixed"
|
||||||
/// it does not have a fixed value. This makes it undefined behavior to have
|
/// meaning "it won't change without being written to"). Reading the same uninitialized byte
|
||||||
/// uninitialized data in a variable even if that variable has an integer type,
|
/// multiple times can give different results. This makes it undefined behavior to have
|
||||||
/// which otherwise can hold any *fixed* bit pattern:
|
/// uninitialized data in a variable even if that variable has an integer type, which otherwise can
|
||||||
|
/// hold any *fixed* bit pattern:
|
||||||
///
|
///
|
||||||
/// ```rust,no_run
|
/// ```rust,no_run
|
||||||
/// # #![allow(invalid_value)]
|
/// # #![allow(invalid_value)]
|
||||||
|
Loading…
Reference in New Issue
Block a user