Skip to content

Commit 2826ff5

Browse files
committed
clarify when reading uninititalized memory is allowed
1 parent 4e6ea83 commit 2826ff5

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/behavior-considered-undefined.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ code.
5757
> **Note**: `rustc` achieves this with the unstable
5858
> `rustc_layout_scalar_valid_range_*` attributes.
5959
60+
Note that uninitialized memory is also implicitly invalid for any type that has
61+
a restricted set of valid values. In other words, the only cases in which
62+
reading uninitialized memory is permitted is inside `union`s, and between the
63+
fields of a compound type (in the "padding").
64+
6065
A reference/pointer is "dangling" if it is null or not all of the bytes it
6166
points to are part of the same allocation (so in particular they all have to be
6267
part of *some* allocation). The span of bytes it points to is determined by the

0 commit comments

Comments
 (0)