https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108342
Bug ID: 108342 Summary: std::complex: ignoring packed attribute because of unpacked non-POD field Product: gcc Version: 12.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: ruilvo at ua dot pt Target Milestone: --- Created attachment 54217 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54217&action=edit Code to reproduce the bug report Summary: With the annexed code, reproduced on the following CE link: https://godbolt.org/z/1q9a5Mq7r I get the following warning: ``` <source>:29:16: warning: ignoring packed attribute because of unpacked non-POD field 'fcomplex_t <unnamed struct>::bb_iq_samples [512]' 29 | fcomplex_t bb_iq_samples[BB_FRAME_IQ_SAMPLES_COUNT]; | ^~~~~~~~~~~~~ ``` Clang doesn't complain facing the same code. Details: I was trying to write a C++ library, which is going to target an ARM Linux system, but leaving C-compatible "bindings" and structs for using with CFFI on other languages. The library deals with a serial stream that I don't control, and that I wanted to de-serialize, thus the weird structure. I discovered the problem (warning) when I changed from a C source file and `_Complex float` to C++ and `std::complex<float>`. The compiler I first discovered the problem on was arm-linux-gnueabihf-g++ (GCC) 12.2.1 20221203 [releases/gcc-12 revision c03cb4b762aceeba95da918b042583af0d9f6030] from Linaro. The bug is reproducible on x86 and mainline GCC (see Compiler Explorer URL) Expected behaviour: For this code to compile without warnings and producing the desired effect (packing). The C++ standard even carves out a guarantee than `_Complex [float|double]` is memory-layout-compatible with `std::complex<[float|double]>`.