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

Charles Davis cdavis at mymail.mines.edu
Mon Feb 22 20:37:32 PST 2010


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.

Chip
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: pr6362-fix.patch
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20100222/620e340f/attachment.ksh>


More information about the cfe-commits mailing list