[cfe-dev] default alignment?
Eric Niebler
eric at boostpro.com
Mon Jan 17 09:38:57 PST 2011
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. A default alignment of 1 byte would lead to
alignment faults all over the place. And consider the following:
#pragma pack(show)
#pragma pack(1)
#pragma pack(show)
Compiled with MSVC, I get:
foo.c(1) : warning C4810: value of pragma pack(show) == 8
foo.c(3) : warning C4810: value of pragma pack(show) == 1
Clearly, the "1" in the last line doesn't refer to a 1 *bit* alignment.
We're talking bytes here.
--
Eric Niebler
BoostPro Computing
http://www.boostpro.com
More information about the cfe-dev
mailing list