Skip to content

Commit

Permalink
Merge pull request #852 from RalfJung/uninit
Browse files Browse the repository at this point in the history
clarify when reading uninititalized memory is allowed
  • Loading branch information
Havvy authored Sep 2, 2020
2 parents 2bd29ae + 8aa6f0f commit 25391db
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/behavior-considered-undefined.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ code.
> **Note**: `rustc` achieves this with the unstable
> `rustc_layout_scalar_valid_range_*` attributes.
**Note:** Uninitialized memory is also implicitly invalid for any type that has
a restricted set of valid values. In other words, the only cases in which
reading uninitialized memory is permitted are inside `union`s and in "padding"
(the gaps between the fields/elements of a type).

A reference/pointer is "dangling" if it is null or not all of the bytes it
points to are part of the same allocation (so in particular they all have to be
part of *some* allocation). The span of bytes it points to is determined by the
Expand Down

0 comments on commit 25391db

Please sign in to comment.