File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -16,7 +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 null, dangling, or unaligned references or raw pointers
19
+ * Loading from or storing to null, dangling, or unaligned references or raw
20
+ pointers
20
21
* Performing out-of-bounds arithmetic for the computation of an
21
22
` enum ` /` struct ` /array/slice/tuple field address
22
23
* Reading [ uninitialized memory] [ ]
@@ -37,6 +38,10 @@ language cares about is preventing the following things:
37
38
"Producing" a value happens any time a value is assigned, passed to a
38
39
function/primitive operation or returned from a function/primitive operation.
39
40
41
+ A reference/pointer is "dangling" if not all of the bytes it points to are part
42
+ of the same allocation. The span of bytes it points to is determined by the
43
+ pointer value and the size of the pointee type.
44
+
40
45
That's it. That's all the causes of Undefined Behavior baked into Rust. Of
41
46
course, unsafe functions and traits are free to declare arbitrary other
42
47
constraints that a program must maintain to avoid Undefined Behavior. For
You can’t perform that action at this time.
0 commit comments