Skip to content

Commit e72976a

Browse files
committed
clarify that references size_of_val can never exceed isize::MAX
1 parent c97d14f commit e72976a

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/behavior-considered-undefined.md

+6-5
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,12 @@ reading uninitialized memory is permitted are inside `union`s and in "padding"
7878
A reference/pointer is "dangling" if it is null or not all of the bytes it
7979
points to are part of the same allocation (so in particular they all have to be
8080
part of *some* allocation). The span of bytes it points to is determined by the
81-
pointer value and the size of the pointee type (using `size_of_val`). As a
82-
consequence, if the span is empty, "dangling" is the same as "non-null". Note
83-
that slices and strings point to their entire range, so it is important that the length
84-
metadata is never too large. In particular, allocations and therefore slices and strings
85-
cannot be bigger than `isize::MAX` bytes.
81+
pointer value and the size of the pointee type (using `size_of_val`).
82+
83+
Note that dynamically sized types (such as slices and strings) point to their
84+
entire range, so it is important that the length metadata is never too large. In
85+
particular, the dynamic size of a Rust value (as determined by `size_of_val`)
86+
must never exceed `isize::MAX`.
8687

8788
[`bool`]: types/boolean.md
8889
[`const`]: items/constant-items.md

0 commit comments

Comments
 (0)