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

            Bug ID: 84108
           Summary: incorrect -Wattributes warning for packed/aligned
                    conflict
           Product: gcc
           Version: 8.0.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: arnd at linaro dot org
  Target Milestone: ---

Marking a struct member as both 'packed' and 'aligned()' triggers a warning in
gcc-8:

struct s {
        char x;
        int y __attribute__((packed, aligned(2)));
        int z __attribute__((aligned(2), packed));
} s;

x86_64-linux-gcc-8.0.1 -c -Wall test.c  -O2 -c
test5.c:3:2: warning: ignoring attribute 'aligned' because it conflicts with
attribute 'packed' [-Wattributes]
  int y __attribute__((packed, aligned(2)));
  ^~~
test5.c:4:2: warning: ignoring attribute 'packed' because it conflicts with
attribute 'aligned' [-Wattributes]
  int z __attribute__((aligned(2), packed));
  ^~~

The warning appears to be a mistake, since neither attribute is in fact ignored
here, and both 'y' and 'z' are aligned to two bytes, which matches the gcc
documentation and the behavior of older versions.

Reply via email to