@@ -42,15 +42,15 @@ code.
42
42
* A null ` fn ` pointer.
43
43
* A value in a ` char ` which is a surrogate or above ` char::MAX ` .
44
44
* A ` ! ` (all values are invalid for this type).
45
+ * [ Uninitialized memory] [ undef ] in the value of an integer (` i* ` /` u* ` ),
46
+ floating point value (` f* ` ), or raw pointer.
45
47
* A dangling or unaligned reference or ` Box ` , or one that points to an invalid value.
46
- * Invalid metadata in a wide reference, ` Box ` or raw pointer:
47
- * slice metadata is invalid if the slice has a total size larger than
48
- ` isize::MAX ` bytes in memory.
48
+ * Invalid metadata in a wide reference, ` Box ` , or raw pointer:
49
49
* ` dyn Trait ` metadata is invalid if it is not a pointer to a vtable for
50
50
` Trait ` that matches the actual dynamic trait the reference points to.
51
+ * Slice metadata is invalid if if the length is not a valid ` usize `
52
+ (i.e., it must not be read from uninitialized memory).
51
53
* Non-UTF-8 byte sequences in a ` str ` .
52
- * [ Uninitialized memory] [ undef ] in the value of an integer (` i* ` /` u* ` ),
53
- floating point value (` f* ` ), or raw pointer.
54
54
* Invalid values for a type with a custom definition of invalid values, such
55
55
as a ` NonNull ` that is null. (Requesting custom invalid values is an
56
56
unstable feature, but some stable libstd types, like ` NonNull ` , make use of
@@ -68,7 +68,8 @@ part of *some* allocation). The span of bytes it points to is determined by the
68
68
pointer value and the size of the pointee type. As a consequence, if the span is
69
69
empty, "dangling" is the same as "non-null". Note that slices point to their
70
70
entire range, so it is very important that the length metadata is never too
71
- large.
71
+ large. In particular, allocations and therefore slices cannot be bigger than
72
+ ` isize::MAX ` bytes.
72
73
73
74
[ noalias ] : http://llvm.org/docs/LangRef.html#noalias
74
75
[ pointer aliasing rules ] : http://llvm.org/docs/LangRef.html#pointer-aliasing-rules
0 commit comments