Description
Summary
Sometimes when accessing a field, the alignment requirement is lower than the type of the field might indicate: specifically, this happens for fields of repr(packed)
structs.
Can the alignment requirement ever be higher? For instance, in this type
#[repr(C)]
struct S { x: u8, y: u32 }
the x
field will always be at a 4-aligned address when occurring inside a well-aligned S
instance. Therefore, Miri will make (*ptr).x
UB if that load is not 4-aligned. This matches codegen which generates an align 4
load in this example.
Is that what we want, or should the alignment requirements of a field access in a struct always be upper-bounded by the alignment of that field?
Reading
https://hackmd.io/rCcTOjQ4SnOb9I2Zt8SqZQ
Comment policy
These issues are meant to be used as an "announcements channel" regarding the proposal, and not as a
place to discuss the technical details. Feel free to subscribe to updates. We'll post comments when
reviewing the proposal in meetings or making a scheduling decision. In the meantime, if you have
questions or ideas, ping the proposers on Zulip (or elsewhere).