Skip to content

Commit 3ce94ca

Browse files
authored
Merge pull request #793 from RalfJung/size-of-val
UB definition: mention size_of_val for determining a reference's span
2 parents c2acacf + 0e53e26 commit 3ce94ca

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
@@ -61,11 +61,11 @@ code.
6161
A reference/pointer is "dangling" if it is null or not all of the bytes it
6262
points to are part of the same allocation (so in particular they all have to be
6363
part of *some* allocation). The span of bytes it points to is determined by the
64-
pointer value and the size of the pointee type. As a consequence, if the span is
65-
empty, "dangling" is the same as "non-null". Note that slices point to their
66-
entire range, so it is important that the length metadata is never too
67-
large. In particular, allocations and therefore slices cannot be bigger than
68-
`isize::MAX` bytes.
64+
pointer value and the size of the pointee type (using `size_of_val`). As a
65+
consequence, if the span is empty, "dangling" is the same as "non-null". Note
66+
that slices point to their entire range, so it is important that the length
67+
metadata is never too large. In particular, allocations and therefore slices
68+
cannot be bigger than `isize::MAX` bytes.
6969

7070
> **Note**: Undefined behavior affects the entire program. For example, calling
7171
> a function in C that exhibits undefined behavior of C means your entire

0 commit comments

Comments
 (0)