Skip to content

Commit 70ae397

Browse files
committed
do not reference LLVM in our definition of UB
1 parent 4d92113 commit 70ae397

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

src/behavior-considered-undefined.md

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,11 @@ r[undefined.place-projection]
4343
[array/slice index expression][project-slice].
4444

4545
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:
5051
* For references, the liveness duration is upper-bounded by the syntactic
5152
lifetime assigned by the borrow checker; it cannot be live any *longer* than
5253
that lifetime.
@@ -56,9 +57,7 @@ r[undefined.alias]
5657
least as long as that function call, again except if the `&T` contains an
5758
[`UnsafeCell<U>`].
5859

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.
6261

6362
r[undefined.immutable]
6463
* Mutating immutable bytes.
@@ -201,7 +200,7 @@ r[undefined.validity.never]
201200

202201
r[undefined.validity.scalar]
203202
* 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.
205204

206205
r[undefined.validity.str]
207206
* 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"
248247

249248
[`bool`]: types/boolean.md
250249
[`const`]: items/constant-items.md
251-
[noalias]: http://llvm.org/docs/LangRef.html#noalias
252-
[pointer aliasing rules]: http://llvm.org/docs/LangRef.html#pointer-aliasing-rules
253250
[abi]: items/external-blocks.md#abi
254-
[undef]: http://llvm.org/docs/LangRef.html#undefined-values
255251
[`target_feature`]: attributes/codegen.md#the-target_feature-attribute
256252
[`UnsafeCell<U>`]: std::cell::UnsafeCell
257253
[Rustonomicon]: ../nomicon/index.html

0 commit comments

Comments
 (0)