Skip to content

Commit 01a12f2

Browse files
authored
Merge pull request #1430 from joshlf/patch-2
type-layout.md: Warn about repr(align)/repr(packed) and field order
2 parents 75d2d5d + a28f858 commit 01a12f2

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/type-layout.md

+4
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,10 @@ assert_eq!(std::mem::size_of::<Enum16>(), 4);
524524
The `align` and `packed` modifiers can be used to respectively raise or lower
525525
the alignment of `struct`s and `union`s. `packed` may also alter the padding
526526
between fields (although it will not alter the padding inside of any field).
527+
On their own, `align` and `packed` do not provide guarantees about the order
528+
of fields in the layout of a struct or the layout of an enum variant, although
529+
they may be combined with representations (such as `C`) which do provide such
530+
guarantees.
527531

528532
The alignment is specified as an integer parameter in the form of
529533
`#[repr(align(x))]` or `#[repr(packed(x))]`. The alignment value must be a

0 commit comments

Comments
 (0)