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

            Bug ID: 88664
           Summary: False positive -Waddress-of-packed-member
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nathan at gcc dot gnu.org
  Target Milestone: ---

Created attachment 45316
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=45316&action=edit
extracted from code using epoll_event structure

nathans@devvm2452:29>./cc1plus -Waddress-of-packed-member ../../../packed.cc
-quiet
../../../packed.cc: In function 'void foo(epoll_event*)':
../../../packed.cc:10:49: warning: taking address of packed member of
'epoll_event' may result in an unaligned pointer value
[-Waddress-of-packed-member]
   10 |   int *actionable = static_cast <int *> (event->ptr);
      |                                          ~~~~~~~^~~

But we're not taking the address of the packed field, we're converting the
value the field holds to a different pointer.

epoll_event is packed, and I imagine more code than mine squirrels away data
pointers in its data field.  I suppose the FE could internally be taking a
reference to preserve lvalueness ...

Reply via email to