public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/108342] New: std::complex: ignoring packed attribute because of unpacked non-POD field
@ 2023-01-09 12:57 ruilvo at ua dot pt
  2023-01-09 16:08 ` [Bug c++/108342] " pinskia at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: ruilvo at ua dot pt @ 2023-01-09 12:57 UTC (permalink / raw)
  To: gcc-bugs

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]>`.

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2023-01-09 21:40 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-09 12:57 [Bug c++/108342] New: std::complex: ignoring packed attribute because of unpacked non-POD field ruilvo at ua dot pt
2023-01-09 16:08 ` [Bug c++/108342] " pinskia at gcc dot gnu.org
2023-01-09 16:13 ` [Bug libstdc++/108342] " pinskia at gcc dot gnu.org
2023-01-09 16:14 ` ruilvo at ua dot pt
2023-01-09 16:16 ` ruilvo at ua dot pt
2023-01-09 16:17 ` redi at gcc dot gnu.org
2023-01-09 16:28 ` [Bug c++/108342] " pinskia at gcc dot gnu.org
2023-01-09 16:31 ` pinskia at gcc dot gnu.org
2023-01-09 16:37 ` pinskia at gcc dot gnu.org
2023-01-09 16:39 ` pinskia at gcc dot gnu.org
2023-01-09 21:23 ` ruilvo at ua dot pt
2023-01-09 21:34 ` jakub at gcc dot gnu.org
2023-01-09 21:40 ` ruilvo at ua dot pt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).