Skip to content

Commit 46bcc6c

Browse files
committed
better explain where the dynamic type of the pointee matters
1 parent 5762212 commit 46bcc6c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/behavior-considered-undefined.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,13 @@ Please read the [Rustonomicon] before writing unsafe code.
7171
* A `!` (all values are invalid for this type).
7272
* An integer (`i*`/`u*`), floating point value (`f*`), or raw pointer obtained
7373
from [uninitialized memory][undef], or uninitialized memory in a `str`.
74-
* A reference or `Box<T>` that is [dangling], misaligned, or points to an invalid value.
74+
* A reference or `Box<T>` that is [dangling], misaligned, or points to an invalid value
75+
(using the actual dynamic type of the pointee as determined by the vtable in
76+
the metadata in case of dynamically sized types).
7577
* Invalid metadata in a wide reference, `Box<T>`, or raw pointer. The requirement
7678
for the metadata is determined by the type of the unsized tail:
7779
* `dyn Trait` metadata is invalid if it is not a pointer to a vtable for
78-
`Trait` that matches the actual dynamic type the pointer or reference points to.
80+
`Trait`.
7981
* Slice metadata is invalid if the length is not a valid `usize`
8082
(i.e., it must not be read from uninitialized memory).
8183
Furthermore, for wide references and `Box<T>`, slice metadata is invalid

0 commit comments

Comments
 (0)