Open
Description
@sunfishcode pointed out here (#1321 (comment)) that when we use explicit padding on C FFI:
struct Foo {
_pad: u32;
pub field: u16
}
Rust will insert copies, etc. for the padding bits, and when users write code like:
let foo = MaybeUninit::<Foo>::zeroed().assume_init();
those fields will be zeroed.
However, if we were to use
#[repr(align(4))]
struct Foo {
pub field: u16,
}
instead, this would not be the case.
We don't have that many types using repr(align)
and repr(packed)
explicitly, so we should manually check those against the C headers, and verify that they only use these attributes when C does so as well.