https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96293
devbeacon <2909820123 at qq dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |2909820123 at qq dot com
--- Comment #11 from devbeacon <2909820123 at qq dot com> ---
Here is a workaround to remove this warning:
Instead of using attribution, using pragma pack/pop
e.g:
#pragma pack(push)
#pragma pack(1) /* set alignment to 1 byte boundary */
struct PackedStruct0 {
char a;
int b;
}__attribute__((packed, aligned(4)));
struct PackedStruct {
char a;
int b;
};
#pragma pack(pop)
void f4s(int* p)
{
*p = 0x12345678;
}
int main()
{
PackedStruct0 ps0;
f4s(&ps0.b); // gcc 11.4.0 will fire Waddress-of-packed-member warning
PackedStruct ps;
f4s(&ps.b); // no warning fired
}