From 01d11b84295ca79a4b12e14bf11fecf4a3a10814 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 24 Jul 2019 12:09:07 +0200 Subject: [PATCH] add more cases of UB --- src/what-unsafe-does.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/what-unsafe-does.md b/src/what-unsafe-does.md index 259f433..873b190 100644 --- a/src/what-unsafe-does.md +++ b/src/what-unsafe-does.md @@ -22,16 +22,21 @@ language cares about is preventing the following things: * Breaking the [pointer aliasing rules][] * Producing invalid primitive values (either alone or as a field of a compound type such as `enum`/`struct`/array/tuple): - * dangling/null/unaligned references + * dangling/null/unaligned references, references that do themselves point to + invalid values, or fat references (to a dynamically sized type) with + invalid metadata * null `fn` pointers * a `bool` that isn't 0 or 1 * an undefined `enum` discriminant * a `char` outside the ranges [0x0, 0xD7FF] and [0xE000, 0x10FFFF] * a non-utf8 `str` + * an uninitialized integer (`i*`/`u*`) or floating point value (`f*`) * an invalid library type with custom invalid values, such as a `NonNull` or `NonZero*` that is 0 * Unwinding into another language * Causing a [data race][race] +* Executing code compiled with platform features that the current platform does + not support (see [`target_feature`]) "Producing" a value happens any time a value is assigned, passed to a function/primitive operation or returned from a function/primitive operation. @@ -69,3 +74,4 @@ these problems are considered impractical to categorically prevent. [pointer aliasing rules]: references.html [uninitialized memory]: uninitialized.html [race]: races.html +[`target_feature`]: ../reference/attributes/codegen.html#the-target_feature-attribute