Consider the following type:
#[derive(IntoBytes)]
#[repr(C, align(8))]
struct Foo<T> {
t: T,
}
#[derive(IntoBytes)] emits an IntoBytes impl for Foo with a T: Unaligned bound. The reasoning is based on the repr(C) layout algorithm, but this reasoning is unsound in the presence of #[repr(align(8))], which #[derive(IntoBytes)] spuriously ignores.
In particular, Foo<u8> satisfies u8: Unaligned, but has size 8 (7 bytes of padding) in order to satisfy its alignment requirement.
We need to either ban #[repr(align(...))] in #[derive(IntoBytes)] or at least ban it when generics are present.
Consider the following type:
#[derive(IntoBytes)]emits anIntoBytesimpl forFoowith aT: Unalignedbound. The reasoning is based on therepr(C)layout algorithm, but this reasoning is unsound in the presence of#[repr(align(8))], which#[derive(IntoBytes)]spuriously ignores.In particular,
Foo<u8>satisfiesu8: Unaligned, but has size 8 (7 bytes of padding) in order to satisfy its alignment requirement.We need to either ban
#[repr(align(...))]in#[derive(IntoBytes)]or at least ban it when generics are present.