[Bug c++/108342] std::complex: ignoring packed attribute because of unpacked non-POD field
jakub at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Jan 9 21:34:47 GMT 2023
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108342
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #11 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Rui Oliveira from comment #10)
> So my options are to create like a placeholder, say
>
> ```c
> typedef struct __attribute__((__packed__)) // Packed isn't really necessary
> here I think?
> {
> float re, im;
> } ph_fcomplex_t
>
> ```
>
> To silence the warning and get packing to work, and trust
> [complex.numbers.general] for a reinterpret_cast into std::complex<float> I
> guess.
No, if you have the packed ph_fcomplex_t not aligned at alignof (float), you
need
to copy it to a properly aligned variable before trying to reinterpret_cast it.
More information about the Gcc-bugs
mailing list