public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/114986] New: Seemingly incorrect "ignoring packed attribute" warning
@ 2024-05-08 13:46 pdimov at gmail dot com
2024-05-08 16:46 ` [Bug c++/114986] " mpolacek at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: pdimov at gmail dot com @ 2024-05-08 13:46 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114986
Bug ID: 114986
Summary: Seemingly incorrect "ignoring packed attribute"
warning
Product: gcc
Version: 14.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: pdimov at gmail dot com
Target Milestone: ---
The following program
```
#include <cstdint>
#include <cstddef>
struct uuid
{
std::uint8_t data[ 16 ] = {};
};
struct __attribute__((packed)) X
{
uuid a;
unsigned char b;
unsigned c;
unsigned char d;
};
static_assert( offsetof(X, c) == 17 );
static_assert( sizeof(X) == 22 );
```
(https://godbolt.org/z/WvxjM3eqn)
gives
```
<source>:11:10: warning: ignoring packed attribute because of unpacked non-POD
field 'uuid X::a'
```
However, the attribute is applied, because the static assertions pass.
If `__attribute__((packed))` is removed, the assertions (correctly) fail
(https://godbolt.org/z/hP4oG98fq).
Therefore, the warning seems wrong.
GCC 14, 13, 12 warn; 11 and earlier do not.
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c++/114986] Seemingly incorrect "ignoring packed attribute" warning
2024-05-08 13:46 [Bug c++/114986] New: Seemingly incorrect "ignoring packed attribute" warning pdimov at gmail dot com
@ 2024-05-08 16:46 ` mpolacek at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2024-05-08 16:46 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114986
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mpolacek at gcc dot gnu.org
--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
The warning appeared with
commit a37e8ce3b66325f0c6de55c80d50ac1664c3d0eb
Author: Jason Merrill <jason@redhat.com>
Date: Tue Dec 14 17:00:40 2021 -0500
c++: layout of aggregate base with DMI [PR103681]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-05-08 16:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-08 13:46 [Bug c++/114986] New: Seemingly incorrect "ignoring packed attribute" warning pdimov at gmail dot com
2024-05-08 16:46 ` [Bug c++/114986] " mpolacek at gcc dot gnu.org
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).