https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114986

--- Comment #2 from TC <rs2740 at gmail dot com> ---
It seems like what it does is that it ignores the attribute's effect on the
specific member, but still applies it on the other members. Consider:

struct Short { short x = {}; };

struct __attribute__((packed)) Y
{
    char a;
    Short b;
    char c;
    int d;
};

static_assert( offsetof(Y, b) == 2 );
static_assert( offsetof(Y, c) == 4 );
static_assert( offsetof(Y, d) == 5 );
static_assert( sizeof(Y) == 10 );
static_assert( alignof(Y) == 2 );

The packed attribute is ignored as to b, so we get 1 byte of padding after `a`,
but it's still applied to d so there's no padding after c; then because of b we
need one byte of padding at the end of the struct.

In the original test case, alignof(uuid) is 1 anyway so ignoring the attribute
is basically a no-op. It might be a good idea to suppress the warning in that
case?

Reply via email to