On Sun, Jan 13, 2019 at 04:48:38AM -0800, H.J. Lu wrote: > When checking alignment of packed member, we should only check the > non-pointer data member. > > gcc/c-family/ > > PR c++/88664 > * c-family/c-warn.c (check_alignment_of_packed_member): Only > check the non-pointer data member.
Doesn't that mean we'd stop warning about: struct S { short s; void *p; } __attribute__ ((__packed__)); void ** foo (struct S *x) { return static_cast <void **> (&x->p); } where we do want to warn? What always matters is whether we take address of a packed structure field/non-static data member or whether we just read that field. The former should be warned about, the latter not. Jakub