[PATCH] D20561: Warn when taking address of packed member

Roger Ferrer Ibanez via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 15 00:26:37 PDT 2016

rogfer01 added a comment.

In https://reviews.llvm.org/D20561#484421, @jyknight wrote:

> This seems to trigger even for the implicitly generated copier of a packed struct. E.g.
>   #include <sys/epoll.h>
>   void copyit(epoll_event&out, const epoll_event &in) {
>     out = in;
>   }
> Is that as intended?

No, it wasn't. It seems to happen as well for the implicit copy constructor as well.

  #include <sys/epoll.h>
  void copyit2(epoll_event foo);
  void copyit(epoll_event &out) { copyit2(out); }

  clang++ -c test.cc
  In file included from test.cc:1:
  /usr/include/x86_64-linux-gnu/sys/epoll.h:87:8: error: binding reference to packed member 'data' of class or structure 'epoll_event'
  struct epoll_event
  test.cc:4:41: note: implicit copy constructor for 'epoll_event' first required here
  void copyit(epoll_event &out) { copyit2(out); }
  1 error generated.



More information about the cfe-commits mailing list