Skip to content

Commit

Permalink
Merge pull request rust-lang#619 from rust-lang-nursery/repr-align-en…
Browse files Browse the repository at this point in the history
…um-docs

Describe `#[repr(align(x))]` semantics on `enum`s
  • Loading branch information
Centril authored Jun 17, 2019
2 parents 1ed0941 + 4bc6227 commit 95cb608
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/type-layout.md
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,10 @@ The `align` and `packed` modifiers cannot be applied on the same type and a
`packed` type cannot transitively contain another `align`ed type. `align` and
`packed` may only be applied to the [default] and [`C`] representations.

The `align` modifier can also be applied on an `enum`.
When it is, the effect on the `enum`'s alignment is the same as if the `enum`
was wrapped in a newtype `struct` with the same `align` modifier.

<div class="warning">

***Warning:*** Dereferencing an unaligned pointer is [undefined behavior] and
Expand Down

0 comments on commit 95cb608

Please sign in to comment.