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: reference/src/glossary.md
+8-1
Original file line number
Diff line number
Diff line change
@@ -179,12 +179,18 @@ requirement of 2.
179
179
180
180
#### Padding
181
181
182
-
*Padding* refers to the space that the compiler leaves between fields of a struct or enum variant to satisfy alignment requirements, and before/after variants of a union or enum to make all variants equally sized.
182
+
*Padding*(of a type `T`) refers to the space that the compiler leaves between fields of a struct or enum variant to satisfy alignment requirements, and before/after variants of a union or enum to make all variants equally sized.
183
183
184
184
Padding can be though of as `[Pad; N]` for some hypothetical type `Pad` (of size 1) with the following properties:
185
185
*`Pad` is valid for any byte, i.e., it has the same validity invariant as `MaybeUninit<u8>`.
186
186
* Copying `Pad` ignores the source byte, and writes *any* value to the target byte. Or, equivalently (in terms of Abstract Machine behavior), copying `Pad` marks the target byte as uninitialized.
187
187
188
+
We can also define padding in terms of the [representation relation]:
189
+
A byte at index `i` is a padding byte for type `T` if,
190
+
for all values `v` and lists of bytes `b` such that `v` and `b` are related at `T` (let's write this `Vrel_T(v, b)`),
191
+
changing `b` at index `i` to any other byte yields a `b'` such `v` and `b'` are related (`Vrel_T(v, b')`).
192
+
In other words, the byte at index `i` is entirely ignored by `Vrel_T` (the value relation for `T`), and two lists of bytes that only differ in padding bytes relate to the same value(s), if any.
193
+
188
194
#### Place
189
195
190
196
A *place* (called "lvalue" in C and "glvalue" in C++) is the result of computing a [*place expression*][place-value-expr].
@@ -208,6 +214,7 @@ Values are ephemeral; they arise during the computation of an instruction but ar
208
214
(This is comparable to how run-time data in a program is ephemeral and is only ever persisted in serialized form.)
0 commit comments