From 4f5888ff54336004f54fe8d37ab264fb8da4726a Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 23 May 2024 07:34:47 +0200 Subject: [PATCH] typo fix and clarifications --- src/behavior-considered-undefined.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/behavior-considered-undefined.md b/src/behavior-considered-undefined.md index 15eb9d18e..96844f79c 100644 --- a/src/behavior-considered-undefined.md +++ b/src/behavior-considered-undefined.md @@ -71,12 +71,13 @@ Please read the [Rustonomicon] before writing unsafe code. * A `!` (all values are invalid for this type). * An integer (`i*`/`u*`), floating point value (`f*`), or raw pointer obtained from [uninitialized memory][undef], or uninitialized memory in a `str`. - * A reference or `Box` that is [dangling], misaligned, or points to an invalid value. + * A reference or `Box` that is [dangling], misaligned, or points to an invalid value + (in case of dynamically sized types, using the actual dynamic type of the + pointee as determined by the metadata). * Invalid metadata in a wide reference, `Box`, or raw pointer. The requirement for the metadata is determined by the type of the unsized tail: - * `dyn Trait` metadata is invalid if it is not a pointer to a vtable for - `Trait` that matches the actual dynamic trait the pointer or reference points to. - * Slice metadata is invalid if the length is not a valid `usize` + * `dyn Trait` metadata is invalid if it is not a pointer to a vtable for `Trait`. + * Slice (`[T]`) metadata is invalid if the length is not a valid `usize` (i.e., it must not be read from uninitialized memory). Furthermore, for wide references and `Box`, slice metadata is invalid if it makes the total size of the pointed-to value bigger than `isize::MAX`.