https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94081
Bug ID: 94081 Summary: -Waddress-of-packed-member doesn’t take variable attributes or __builtin_assume_aligned into account Product: gcc Version: 9.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: felix.von.s at posteo dot de Target Milestone: --- In this code: #include <stdint.h> struct foo { uint16_t a, b; } __attribute__((packed)); extern struct foo *f(void); extern void g(uint16_t *p); void h(void) { struct foo *s0 = __builtin_assume_aligned(f(), 16); g(&s0->a); struct foo s1 __attribute__ ((aligned(16))); g(&s1.a); } GCC will warn about taking the address of s0->a and s1.a, even though it has enough information to recognise those as false positives. On many platforms, variables on the stack are naturally aligned at a 32-bit boundary, so I believe &s1.a is a false positive on those platforms as well, but I’m less sure if skipping the warning for this case is desirable.