You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/behavior-considered-undefined.md
+7-11Lines changed: 7 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -43,10 +43,11 @@ r[undefined.place-projection]
43
43
[array/slice index expression][project-slice].
44
44
45
45
r[undefined.alias]
46
-
* Breaking the [pointer aliasing rules]. `Box<T>`, `&mut T` and `&T` follow
47
-
LLVM’s scoped [noalias] model, except if the `&T` contains an
48
-
[`UnsafeCell<U>`]. References and boxes must not be [dangling] while they are
49
-
live. The exact liveness duration is not specified, but some bounds exist:
46
+
* Breaking the pointer aliasing rules. The exact aliasing rules are not determined yet, but here is a rough sketch of what the requirements look like:
47
+
`&T` must point to memory that is not mutated while they are live (except for data inside an [`UnsafeCell<U>`]),
48
+
and `&mut T` must point to memory that is not read or written by any pointer not derived from the reference and that no other reference points to while they are live.
49
+
`Box<T>` is treated similar to `&'static mut T` for the purpose of these rules.
50
+
The exact liveness duration is not specified, but some bounds exist:
50
51
* For references, the liveness duration is upper-bounded by the syntactic
51
52
lifetime assigned by the borrow checker; it cannot be live any *longer* than
52
53
that lifetime.
@@ -56,9 +57,7 @@ r[undefined.alias]
56
57
least as long as that function call, again except if the `&T` contains an
57
58
[`UnsafeCell<U>`].
58
59
59
-
All this also applies when values of these
60
-
types are passed in a (nested) field of a compound type, but not behind
61
-
pointer indirections.
60
+
All this also applies when values of these types are passed in a (nested) field of a compound type, but not behind pointer indirections.
62
61
63
62
r[undefined.immutable]
64
63
* Mutating immutable bytes.
@@ -201,7 +200,7 @@ r[undefined.validity.never]
201
200
202
201
r[undefined.validity.scalar]
203
202
* An integer (`i*`/`u*`), floating point value (`f*`), or raw pointer must be
204
-
initialized, i.e., must not be obtained from [uninitialized memory][undef].
203
+
initialized, i.e., must not be obtained from uninitialized memory.
205
204
206
205
r[undefined.validity.str]
207
206
* A `str` value is treated like `[u8]`, i.e. it must be initialized.
@@ -248,10 +247,7 @@ reading uninitialized memory is permitted are inside `union`s and in "padding"
0 commit comments