This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Fix 21166

Richard Henderson wrote:
On Tue, May 10, 2005 at 03:27:57PM +0100, Nathan Sidwell wrote:

+   /* We might be able to clear DECL_PACKED on any members that happen
+      to be suitably aligned (not forgetting the alignment of the type
+      itself).  */
+   for (field = TYPE_FIELDS (rli->t); field; field = TREE_CHAIN (field))
+     if (TREE_CODE (field) == FIELD_DECL && DECL_PACKED (field)
+ 	&& DECL_OFFSET_ALIGN (field) >= TYPE_ALIGN (TREE_TYPE (field))
+ 	&& TYPE_ALIGN (rli->t) >= TYPE_ALIGN (TREE_TYPE (field)))
+       DECL_PACKED (field) = 0;

Any reason not to do this in layout_decl where we handle the other
aspects of overalignment?  Seems to me that the known_align argument
can be used just like you want.

when we're laying out the field_decl of one field we won't know if a later field forces the struct to have a larger alignment.

struct X {
int __attribute__((packed)) a;
int b;

we'd want to set X::a as unpacked here.


Nathan Sidwell    ::   ::     CodeSourcery LLC    ::

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]