We recently had a bug where we were inadvertently taking an address of a packed member inside some template code. std::addressof appears to prevent -Waddress-of-packed-member diagnostics. It would be good if clang somehow treated std::addressof(x) as equivalent to &a for the purposes of providing diagnostics for -Waddress-of-packed-member.
In general, it looks like clang doesn't diagnose when an lvalue reference is taken to an unaligned member. For our use-case, it would be nice if -Waddress-of-packed-member would diagnose all lvalue references to unaligned members. Although I could understand if just adding a heuristic for std::addressof is more palatable.
We recently had a bug where we were inadvertently taking an address of a packed member inside some template code.
std::addressof
appears to prevent-Waddress-of-packed-member
diagnostics. It would be good if clang somehow treatedstd::addressof(x)
as equivalent to&a
for the purposes of providing diagnostics for-Waddress-of-packed-member
.Godbolt minimal example
In general, it looks like clang doesn't diagnose when an lvalue reference is taken to an unaligned member. For our use-case, it would be nice if -Waddress-of-packed-member would diagnose all lvalue references to unaligned members. Although I could understand if just adding a heuristic for
std::addressof
is more palatable.