You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/behavior-considered-undefined.md
+6-8Lines changed: 6 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -100,16 +100,13 @@ r[undefined.dangling]
100
100
[dangling]: #dangling-pointers
101
101
102
102
r[undefined.dangling.def]
103
-
A reference/pointer is "dangling" if not all of the bytes it [points to] are part of the same live allocation (so in particular they all have to be part of *some* allocation).
103
+
A reference/pointer is "dangling" if not all of the bytes it [points to] are part of the same live [allocation] (so in particular they all have to be part of *some* allocation).
104
104
105
-
r[undefined.dangling.zero-size]
106
-
If the [size is 0][zero-sized], then the pointer is trivially never "dangling" (even if it is a null pointer).
107
-
108
-
r[undefined.dangling.dynamic-size]
109
-
Note that dynamically sized types (such as slices and strings) point to their entire range, so it is important that the length [metadata] is never too large.
105
+
> [!NOTE]
106
+
> This implies that the dynamic size of a Rust value (as determined by `size_of_val`) must never exceed `isize::MAX`, since it is impossible for a single allocation to be larger than `isize::MAX`.
110
107
111
-
r[undefined.dangling.alloc-limit]
112
-
In particular, the dynamic size of a Rust value (as determined by `size_of_val`) must never exceed `isize::MAX`, since it is impossible for a single allocation to be larger than `isize::MAX`.
108
+
> [!NOTE]
109
+
> This also implies that if the [size is 0][zero-sized], then the pointer is trivially never "dangling" (even if it is a null pointer).
0 commit comments