arocc icon indicating copy to clipboard operation
arocc copied to clipboard

Add diagnostic for taking address of packed record member

Open ehaas opened this issue 1 year ago • 0 comments

struct __attribute__((packed)) Foo {
    int x;
};
struct Foo foo;
int *p = &foo.x;
test.c:5:11: warning: taking address of packed member 'x' of class or structure 'Foo' may result in an unaligned pointer value [-Waddress-of-packed-member]

This check can go in the same place as the addr_of_bitfield check.

ehaas avatar Oct 14 '24 16:10 ehaas