Skip to content

Commit bb7b8ba

Browse files
committed
elaborate on slice wide pointer metadata
1 parent e356977 commit bb7b8ba

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/behavior-considered-undefined.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,14 @@ Please read the [Rustonomicon] before writing unsafe code.
7272
* An integer (`i*`/`u*`), floating point value (`f*`), or raw pointer obtained
7373
from [uninitialized memory][undef], or uninitialized memory in a `str`.
7474
* A reference or `Box<T>` that is [dangling], misaligned, or points to an invalid value.
75-
* Invalid metadata in a wide reference, `Box<T>`, or raw pointer:
75+
* Invalid metadata in a wide reference, `Box<T>`, or raw pointer. The requirement
76+
for the metadata is determined by the type of the unsized tail:
7677
* `dyn Trait` metadata is invalid if it is not a pointer to a vtable for
7778
`Trait` that matches the actual dynamic trait the pointer or reference points to.
7879
* Slice metadata is invalid if the length is not a valid `usize`
7980
(i.e., it must not be read from uninitialized memory).
81+
Furthermore, for wide references and `Box<T>`, slice metadata is invalid
82+
if it makes the total size of the type bigger than `isize::MAX`.
8083
* Invalid values for a type with a custom definition of invalid values.
8184
In the standard library, this affects [`NonNull<T>`] and [`NonZero*`].
8285

0 commit comments

Comments
 (0)