[cfe-dev] __attribute__((packed, aligned(4)))?

Eli Friedman eli.friedman at gmail.com
Sun Jun 30 16:49:58 PDT 2013


On Sun, Jun 30, 2013 at 10:38 AM, Tim Northover <t.p.northover at gmail.com>wrote:

> Hi,
>
> Does anyone have a good model for how the "packed" and "aligned"
> attributes interact?
>
> For example:
>
> struct Foo __attribute__((packed, aligned(4))) {
>     int a;
>     char b;
>     int c;
> };
>
> struct Foo var;
>
> It seems that alignof(var) == 4, but alignof(var.a) == 1. This is
> surprising to me.
>
> Is this just a GCC quirk that we've had to emulate or is there a good
> reason for it?
>

This is what gcc does.  It's not worth trying to deviate from gcc here.

-Eli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130630/3ca82cd3/attachment.html>


More information about the cfe-dev mailing list