23
23
</div >
24
24
25
25
* Data races.
26
- * Dereferencing (using the ` * ` operator on) a dangling or unaligned raw pointer.
26
+ * Evaluating a dereference [ place expression] (` *expr ` ) on a raw pointer that is
27
+ [ dangling] or unaligned.
27
28
* Breaking the [ pointer aliasing rules] . ` &mut T ` and ` &T ` follow LLVM’s scoped
28
29
[ noalias] model, except if the ` &T ` contains an [ ` UnsafeCell<U> ` ] .
29
30
* Mutating immutable data. All data inside a [ ` const ` ] item is immutable. Moreover, all
45
46
* A ` ! ` (all values are invalid for this type).
46
47
* An integer (` i* ` /` u* ` ), floating point value (` f* ` ), or raw pointer obtained
47
48
from [ uninitialized memory] [ undef ] , or uninitialized memory in a ` str ` .
48
- * A reference or ` Box<T> ` that is dangling, unaligned, or points to an invalid value.
49
+ * A reference or ` Box<T> ` that is [ dangling] , unaligned, or points to an invalid value.
49
50
* Invalid metadata in a wide reference, ` Box<T> ` , or raw pointer:
50
51
* ` dyn Trait ` metadata is invalid if it is not a pointer to a vtable for
51
52
` Trait ` that matches the actual dynamic trait the pointer or reference points to.
@@ -62,6 +63,17 @@ a restricted set of valid values. In other words, the only cases in which
62
63
reading uninitialized memory is permitted are inside ` union ` s and in "padding"
63
64
(the gaps between the fields/elements of a type).
64
65
66
+ > ** Note** : Undefined behavior affects the entire program. For example, calling
67
+ > a function in C that exhibits undefined behavior of C means your entire
68
+ > program contains undefined behaviour that can also affect the Rust code. And
69
+ > vice versa, undefined behavior in Rust can cause adverse affects on code
70
+ > executed by any FFI calls to other languages.
71
+
72
+ [ place expression ] : expressions.md#place-expressions-and-value-expressions
73
+
74
+ ### Dangling pointers
75
+ [ dangling ] : #dangling-pointers
76
+
65
77
A reference/pointer is "dangling" if it is null or not all of the bytes it
66
78
points to are part of the same allocation (so in particular they all have to be
67
79
part of * some* allocation). The span of bytes it points to is determined by the
@@ -71,12 +83,6 @@ that slices and strings point to their entire range, so it is important that the
71
83
metadata is never too large. In particular, allocations and therefore slices and strings
72
84
cannot be bigger than ` isize::MAX ` bytes.
73
85
74
- > ** Note** : Undefined behavior affects the entire program. For example, calling
75
- > a function in C that exhibits undefined behavior of C means your entire
76
- > program contains undefined behaviour that can also affect the Rust code. And
77
- > vice versa, undefined behavior in Rust can cause adverse affects on code
78
- > executed by any FFI calls to other languages.
79
-
80
86
[ `bool` ] : types/boolean.md
81
87
[ `const` ] : items/constant-items.md
82
88
[ noalias ] : http://llvm.org/docs/LangRef.html#noalias
0 commit comments