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

Ivan Sorokin <vanyacpp at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |vanyacpp at gmail dot com

--- Comment #8 from Ivan Sorokin <vanyacpp at gmail dot com> ---
Note that when __attribute__((packed)) is used GCC produces a warning:

warning: taking address of packed member of '<unnamed struct>' may result in an
unaligned pointer value [-Waddress-of-packed-member]
   10 |     int *d = &c.b;
      |              ^~~~

Perhaps a similar warning should be reported for #pragma packed structs.

https://godbolt.org/z/Yr13WhbG8

struct
{
  char a;
  int b;
} __attribute__((packed)) c;

int main()
{
    int *d = &c.b;
    __builtin_printf("%d\n", *d);
}

Reply via email to