Skip to content

Commit 01d11b8

Browse files
RalfJungGankra
authored andcommitted
add more cases of UB
1 parent a7aa0a8 commit 01d11b8

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/what-unsafe-does.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,21 @@ language cares about is preventing the following things:
2222
* Breaking the [pointer aliasing rules][]
2323
* Producing invalid primitive values (either alone or as a field of a compound
2424
type such as `enum`/`struct`/array/tuple):
25-
* dangling/null/unaligned references
25+
* dangling/null/unaligned references, references that do themselves point to
26+
invalid values, or fat references (to a dynamically sized type) with
27+
invalid metadata
2628
* null `fn` pointers
2729
* a `bool` that isn't 0 or 1
2830
* an undefined `enum` discriminant
2931
* a `char` outside the ranges [0x0, 0xD7FF] and [0xE000, 0x10FFFF]
3032
* a non-utf8 `str`
33+
* an uninitialized integer (`i*`/`u*`) or floating point value (`f*`)
3134
* an invalid library type with custom invalid values, such as a `NonNull` or
3235
`NonZero*` that is 0
3336
* Unwinding into another language
3437
* Causing a [data race][race]
38+
* Executing code compiled with platform features that the current platform does
39+
not support (see [`target_feature`])
3540

3641
"Producing" a value happens any time a value is assigned, passed to a
3742
function/primitive operation or returned from a function/primitive operation.
@@ -69,3 +74,4 @@ these problems are considered impractical to categorically prevent.
6974
[pointer aliasing rules]: references.html
7075
[uninitialized memory]: uninitialized.html
7176
[race]: races.html
77+
[`target_feature`]: ../reference/attributes/codegen.html#the-target_feature-attribute

0 commit comments

Comments
 (0)