Skip to content

Commit 25391db

Browse files
authored
Merge pull request #852 from RalfJung/uninit
clarify when reading uninititalized memory is allowed
2 parents 2bd29ae + 8aa6f0f commit 25391db

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/behavior-considered-undefined.md

+5
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:** 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 are inside `union`s and in "padding"
63+
(the gaps between the fields/elements of a type).
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)