@@ -16,8 +16,8 @@ to your program. You definitely *should not* invoke Undefined Behavior.
1616Unlike C, Undefined Behavior is pretty limited in scope in Rust. All the core
1717language cares about is preventing the following things:
1818
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)
2121* Reading [ uninitialized memory] [ ]
2222* Breaking the [ pointer aliasing rules] [ ]
2323* Unwinding into another language
@@ -31,7 +31,7 @@ language cares about is preventing the following things:
3131 * null ` fn ` pointers
3232 * a ` char ` outside the ranges [ 0x0, 0xD7FF] and [ 0xE000, 0x10FFFF]
3333 * 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
3535 invalid values, or wide references (to a dynamically sized type) with
3636 invalid metadata
3737 * 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:
4848function/primitive operation or returned from a function/primitive operation.
4949
5050A 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".
5354
5455That's it. That's all the causes of Undefined Behavior baked into Rust. Of
5556course, unsafe functions and traits are free to declare arbitrary other
0 commit comments