Open
Description
When converting C structures that are both packed and aligned using either C2Rust or bindgen, such as:
struct xregs_state {
struct fxregs_state i387;
struct xstate_header header;
u8 extended_state_area[0];
} __attribute__ ((packed, aligned (64)));
the code that either tool produces looks something like:
#[repr(C, packed(64))]
#[repr(align(64))]
pub struct xregs_state {
pub i387: fxregs_state,
pub header: xstate_header,
pub extended_state_area: __IncompleteArrayField<u8>,
}
This Rust code fails to compile due to error E0587
:
error[E0587]: type has conflicting packed and align representation hints
--> .../out/bindings.rs:3894:1
|
3894 | / pub struct xregs_state {
3895 | | pub i387: fxregs_state,
3896 | | pub header: xstate_header,
3897 | | pub extended_state_area: __IncompleteArrayField<u8>,
3898 | | }
| |_^
We can work around this in C2Rust by emitting an aligned outer/packed inner structure pair (I think bindgen could do the same), but I'm wondering if it would be better to fix this on the Rust language/compiler side.
Metadata
Metadata
Assignees
Labels
Area: Foreign function interface (FFI)Area: Messages for errors, warnings, and lintsArea: the naughtiest reprCategory: An issue proposing an enhancement or a PR with one.Relevant to the compiler team, which will review and decide on the PR/issue.Relevant to the language team, which will review and decide on the PR/issue.