Skip to content

Commit f051866

Browse files
authored
Merge pull request #1541 from RalfJung/zero-sized
update 'dangling pointers' to new zero-sized rules
2 parents a55278c + 2935cdc commit f051866

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/behavior-considered-undefined.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -142,18 +142,18 @@ new reference is aligned, but it is not always necessary.
142142
### Dangling pointers
143143
[dangling]: #dangling-pointers
144144

145-
A reference/pointer is "dangling" if it is null or not all of the bytes it
145+
A reference/pointer is "dangling" if not all of the bytes it
146146
[points to] are part of the same live allocation (so in particular they all have to be
147147
part of *some* allocation).
148148

149-
If the size is 0, then the pointer must either point inside of a live allocation
150-
(including pointing just after the last byte of the allocation), or it must be
151-
directly constructed from a non-zero integer literal.
149+
If the size is 0, then the pointer is trivially never "dangling"
150+
(even if it is a null pointer).
152151

153152
Note that dynamically sized types (such as slices and strings) point to their
154153
entire range, so it is important that the length metadata is never too large. In
155154
particular, the dynamic size of a Rust value (as determined by `size_of_val`)
156-
must never exceed `isize::MAX`.
155+
must never exceed `isize::MAX`, since it is impossible for a single allocation
156+
to be larger than `isize::MAX`.
157157

158158
[`bool`]: types/boolean.md
159159
[`const`]: items/constant-items.md

0 commit comments

Comments
 (0)