https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84108
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |diagnostic Status|UNCONFIRMED |NEW Last reconfirmed| |2018-01-29 Known to work| |5.1.0, 6.3.0, 7.2.0 Summary|incorrect -Wattributes |[8 Regression] incorrect |warning for packed/aligned |-Wattributes warning for |conflict |packed/aligned conflict on | |struct members Ever confirmed|0 |1 Known to fail| |8.0 --- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> --- Confirmed. Looks like I missed that the two attributes are treated differently when used with struct members than with standalone objects. Here's a test case showing the differences and the expected/bogus warnings: $ cat pr84108.c && gcc -O2 -S -Wall pr84108.c #define A(e) _Static_assert (e, #e) int i2 __attribute__((packed, aligned (2))); // -Wattributes int j2 __attribute__((aligned (2), packed)); // -Wattributes int i1 __attribute__((aligned (2))); // okay (reduces alignment) A (_Alignof (i2) == 2); A (_Alignof (j2) == 2); A (_Alignof (i1) == 2); struct { int i2 __attribute__((packed, aligned (2))); // bogus -Wattributes in GCC 8 int j2 __attribute__((aligned (2), packed)); // bogus -Wattributes in GCC 8 int i1 __attribute__((aligned (2))); // ignored, no warning } s; A (_Alignof (s.i2) == 2); A (_Alignof (s.j2) == 2); A (_Alignof (s.i1) == 4); pr84108.c:3:1: warning: ‘packed’ attribute ignored [-Wattributes] int i2 __attribute__((packed, aligned (2))); // -Wattributes ^~~ pr84108.c:4:1: warning: ‘packed’ attribute ignored [-Wattributes] int j2 __attribute__((aligned (2), packed)); // -Wattributes ^~~ pr84108.c:12:3: warning: ignoring attribute ‘aligned’ because it conflicts with attribute ‘packed’ [-Wattributes] int i2 __attribute__((packed, aligned (2))); // bogus -Wattributes in GCC 8 ^~~ pr84108.c:13:3: warning: ignoring attribute ‘packed’ because it conflicts with attribute ‘aligned’ [-Wattributes] int j2 __attribute__((aligned (2), packed)); // bogus -Wattributes in GCC 8 ^~~