-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
#[repr(align(N))] fields not allowed in #[repr(packed(M>=N))] structs #100743
Copy link
Copy link
Open
Labels
A-alignArea: alignment control (`repr(align(N))` and so on)Area: alignment control (`repr(align(N))` and so on)A-layoutArea: Memory layout of typesArea: Memory layout of typesA-reprArea: the `#[repr(stuff)]` attributeArea: the `#[repr(stuff)]` attributeA-repr-packedArea: the naughtiest reprArea: the naughtiest reprC-bugCategory: This is a bug.Category: This is a bug.O-windows-msvcToolchain: MSVC, Operating system: WindowsToolchain: MSVC, Operating system: Windows
Metadata
Metadata
Assignees
Labels
A-alignArea: alignment control (`repr(align(N))` and so on)Area: alignment control (`repr(align(N))` and so on)A-layoutArea: Memory layout of typesArea: Memory layout of typesA-reprArea: the `#[repr(stuff)]` attributeArea: the `#[repr(stuff)]` attributeA-repr-packedArea: the naughtiest reprArea: the naughtiest reprC-bugCategory: This is a bug.Category: This is a bug.O-windows-msvcToolchain: MSVC, Operating system: WindowsToolchain: MSVC, Operating system: Windows
Type
Fields
Give feedbackNo fields configured for issues without a type.
I tried this code:
I expected that
#[repr(align(4))]fields, such asAtomicU32, would be allowed inside a#[repr(packed(4))]struct, since the minimum alignment is >= the required alignment.However, the compiler complains:
Use case: I have some fixed-layout shared memory structs I need to interact with, which sometimes contain unaligned u64s. I also need to use atomics on other parts of them (hopefully only u32s).
Meta
rustc --version --verbose: