Skip to content

Commit 6220e00

Browse files
authored
Rollup merge of rust-lang#82837 - RalfJung:maybe-uninit, r=dtolnay
tweak MaybeUninit docs Explain what "(no) fixed value" means.
2 parents 74ae20e + b751548 commit 6220e00

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

library/core/src/mem/maybe_uninit.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,11 @@ use crate::ptr;
3939
/// let b: bool = unsafe { MaybeUninit::uninit().assume_init() }; // undefined behavior! ⚠️
4040
/// ```
4141
///
42-
/// Moreover, uninitialized memory is special in that the compiler knows that
43-
/// it does not have a fixed value. This makes it undefined behavior to have
44-
/// uninitialized data in a variable even if that variable has an integer type,
45-
/// which otherwise can hold any *fixed* bit pattern:
42+
/// Moreover, uninitialized memory is special in that it does not have a fixed value ("fixed"
43+
/// meaning "it won't change without being written to"). Reading the same uninitialized byte
44+
/// multiple times can give different results. This makes it undefined behavior to have
45+
/// uninitialized data in a variable even if that variable has an integer type, which otherwise can
46+
/// hold any *fixed* bit pattern:
4647
///
4748
/// ```rust,no_run
4849
/// # #![allow(invalid_value)]

0 commit comments

Comments
 (0)