[Bug c++/108342] std::complex: ignoring packed attribute because of unpacked non-POD field

pinskia at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Jan 9 16:31:46 GMT 2023


--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #5)
> I don't know whether clang allows packing non-PODs, or just doesn't ever
> warn for them, or has a special case for std::complex, or does something
> smarter like not warn for types that have no padding bytes anyway (so that
> packing them would be a no-op).

clang allows packing of non-PODs:
class f
  int t[2];

typedef struct __attribute__((__packed__))
    /** Every frame starts with BB_FRAME_MAGIC. */
    unsigned magic;
    unsigned char t;

    f bb_iq_samples[100];

} bb_frame_t;

More information about the Gcc-bugs mailing list