@@ -16,8 +16,8 @@ to your program. You definitely *should not* invoke Undefined Behavior.
16
16
Unlike C, Undefined Behavior is pretty limited in scope in Rust. All the core
17
17
language cares about is preventing the following things:
18
18
19
- * Dereferencing (using the ` * ` operator on) null, dangling, or unaligned
20
- pointers, or wide pointers with invalid metadata (see below)
19
+ * Dereferencing (using the ` * ` operator on) dangling, or unaligned pointers, or
20
+ wide pointers with invalid metadata (see below)
21
21
* Reading [ uninitialized memory] [ ]
22
22
* Breaking the [ pointer aliasing rules] [ ]
23
23
* Unwinding into another language
@@ -31,7 +31,7 @@ language cares about is preventing the following things:
31
31
* null ` fn ` pointers
32
32
* a ` char ` outside the ranges [ 0x0, 0xD7FF] and [ 0xE000, 0x10FFFF]
33
33
* a ` ! ` (all values are invalid for this type)
34
- * dangling/null/ unaligned references, references that do themselves point to
34
+ * dangling/unaligned references, references that do themselves point to
35
35
invalid values, or wide references (to a dynamically sized type) with
36
36
invalid metadata
37
37
* slice metadata is invalid if the slice has a total size larger than
@@ -48,8 +48,9 @@ language cares about is preventing the following things:
48
48
function/primitive operation or returned from a function/primitive operation.
49
49
50
50
A reference/pointer is "dangling" if not all of the bytes it points to are part
51
- of the same allocation. The span of bytes it points to is determined by the
52
- pointer value and the size of the pointee type.
51
+ of the same allocation. In particular, null pointers are dangling. The span of bytes it
52
+ points to is determined by the pointer value and the size of the pointee type.
53
+ If the span is empty, "dangling" is the same as "non-null".
53
54
54
55
That's it. That's all the causes of Undefined Behavior baked into Rust. Of
55
56
course, unsafe functions and traits are free to declare arbitrary other
0 commit comments