[cfe-commits] [PATCH] Fix __alignof__ behavior with a field as the operand

Charles Davis cdavis at mymail.mines.edu
Mon Feb 22 20:53:23 PST 2010


Anders Carlsson wrote:
> 
> 22 feb 2010 kl. 20.37 skrev Charles Davis:
> 
>> This patch fixes __alignof__ to behave the same as GCC when a reference
>> to a field of a struct is the operand. This fixes PR6362.
>>
>> GCC returns the lesser of the alignment of the type of the field or the
>> packed alignment of the struct in this situation. Right now, clang just
>> returns the alignment of the type, no matter what. This means that the
>> behavior of clang deviates from GCC when a field of a packed struct
>> (i.e. one with the 'packed' attribute or one declared after a pack
>> pragma) is the operand.
>>
>> Software in the wild (e.g., Wine) already depends on this behavior.
>>
>> This is a simple patch, but I wanted to run it past you guys before
>> committing.
>>
> 
> Hi Charles,
> 
> patch looks good. I assume all tests pass? :)
Of course. Otherwise, I wouldn't even consider posting to this list. :)
> 
>> +      // In the case of a field in a packed struct, we want the MINIMUM
> 
> No need to shout here :), plz change to "minimum".
Done. I wanted to emphasize that it's the minimum we want as opposed to
the maximum. I guess that's not really necessary.

Committed as r96884.

Chip




More information about the cfe-commits mailing list