Skip to content

-Waddress-of-packed-member flags attribute(packed) but not pragma pack #97091

Open
@davidben

Description

@davidben

In this example, there are two packed (and thus unaligned) structs, both of whom have an int field where taking the address is dangerous, as I understand it:
https://godbolt.org/z/PdqaMoeof

But for some reason, -Waddress-of-packed-member only flags the first one, and not the second. Is that intentional? I think they both run afoul of pointer alignment requirements. I noticed #23195 was filed back in 2016, but it was closed on grounds that Clang doesn't accept #pragma pack.

It seems Clang now does, but the warning was never updated?

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerconfirmedVerified by a second partyfalse-negative

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions