[cfe-dev] default alignment?
edwintorok at gmail.com
Mon Jan 17 09:49:36 PST 2011
On 2011-01-17 19:38, Eric Niebler wrote:
> On 1/18/2011 12:20 AM, Chris Lattner wrote:
>> On Jan 17, 2011, at 1:28 AM, Eric Niebler wrote:
>>> In Sema::ActOnPragmaPack, I see this:
>>> // FIXME: This should come from the target.
>>> if (AlignmentVal == 0)
>>> AlignmentVal = 8;
>>> So, what's the right fix? Should this be
>>> (Context.Target.getDoubleAlign() / Context.Target.getCharWidth())? (And
>>> why 8? Where does that come from?)
>> Hi Eric,
>> I'm not familiar with #pragma pack show, but the 8 here is in bits. The right fix is probably to call Context.Target.getCharWidth().
> Hi Chris,
> That's just can't be right.
It is in bytes, see
> A default alignment of 1 byte would lead to
> alignment faults all over the place.
Actually an alignment of 1 byte means that none of your struct elements
are aligned, and that the compiler should emit byte-level reads
even for larger fields on architectures that don't support unaligned
More information about the cfe-dev