Martin Sebor <msebor at gcc dot> changed:

           What    |Removed                     |Added
           Keywords|                            |diagnostic
                 CC|                            |msebor at gcc dot

--- Comment #5 from Martin Sebor <msebor at gcc dot> ---
I think the -Wpacked-not-aligned warning would work well here.  There was a
request some time ago to issue a warning for things like:

  struct __attribute__ ((packed)) S {
    std::mutex mtx;

Decorating std::mutex (and other C++ standard library classes that need to be
aligned) with attribute warn_if_not_aligned would trigger the warning.

Alternatively, adding a new #pragma warn_if_not_aligned to effectively annotate
all type definitions in a header with the attribute would avoid having to
modify every class in the C++ standard library to add the attribute explicitly.

Another alternative would be to implicitly reset the #pragma pack on "entry" to
every C++ standard header (or even every header), and restore it on "exit."

Reply via email to