https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93910
--- Comment #6 from stephane.goujet at wanadoo dot fr --- (In reply to Andreas Schwab from comment #5) > The packed attribute forces the alignment to 1, so there is no requirement > for its address to be aligned for its type. So one could say that the __packed__ attribute has an external effect on top of the internal effect (the expected effect on members). Right? If I read <https://gcc.gnu.org/onlinedocs/gcc-9.2.0/gcc/Common-Type-Attributes.html#Common-Type-Attributes>, I cannot see anything like that, it only talks about members placement. If what you say is true, it would be good to mention it. ---------------------- packed This attribute, attached to a struct, union, or C++ class type definition, specifies that each of its members (other than zero-width bit-fields) is placed to minimize the memory required. This is equivalent to specifying the packed attribute on each of the members. When attached to an enum definition, the packed attribute indicates that the smallest integral type should be used. Specifying the -fshort-enums flag on the command line is equivalent to specifying the packed attribute on all enum definitions. In the following example struct my_packed_struct’s members are packed closely together, but the internal layout of its s member is not packed—to do that, struct my_unpacked_struct needs to be packed too. struct my_unpacked_struct { char c; int i; }; struct __attribute__ ((__packed__)) my_packed_struct { char c; int i; struct my_unpacked_struct s; }; You may only specify the packed attribute on the definition of an enum, struct, union, or class, not on a typedef that does not also define the enumerated type, structure, union, or class. ----------------------- There is a little something in the 'aligned' attribute documentation, but it is unclear. So the solution to the initial test would be to declare the struct as: ---------------------- struct __attribute__((__aligned__(4))) __attribute__ ((__packed__)) S { int a; }; ---------------------- You agree with that? Indeed it doesn't trigger the warning any more.