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

            Bug ID: 114986
           Summary: Seemingly incorrect "ignoring packed attribute"
                    warning
           Product: gcc
           Version: 14.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pdimov at gmail dot com
  Target Milestone: ---

The following program
```
#include <cstdint>
#include <cstddef>

struct uuid
{
    std::uint8_t data[ 16 ] = {};
};

struct __attribute__((packed)) X
{
    uuid a;
    unsigned char b;
    unsigned c;
    unsigned char d;
};

static_assert( offsetof(X, c) == 17 );
static_assert( sizeof(X) == 22 );
```
(https://godbolt.org/z/WvxjM3eqn)

gives
```
<source>:11:10: warning: ignoring packed attribute because of unpacked non-POD
field 'uuid X::a'
```

However, the attribute is applied, because the static assertions pass.

If `__attribute__((packed))` is removed, the assertions (correctly) fail
(https://godbolt.org/z/hP4oG98fq).

Therefore, the warning seems wrong.

GCC 14, 13, 12 warn; 11 and earlier do not.

Reply via email to