This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
__attribute__((packed)) and trivial types
- From: Pedro Lamarão <pedro dot lamarao at gmail dot com>
- To: gcc at gcc dot gnu dot org
- Date: Tue, 27 Mar 2012 23:33:46 -0300
- Subject: __attribute__((packed)) and trivial types
With GCC 4.7 and the following program:
--
struct byte
{
unsigned char _;
byte () = default;
explicit operator unsigned char () { return _; }
};
struct wyde
{
unsigned short _;
wyde () = default;
constexpr wyde (unsigned short r) : _(r) { }
};
struct foo
{
byte one;
wyde two;
}
__attribute__((packed));
auto main (int argc, char * argv[]) -> int
{
foo f;
return 0;
}
--
I am receiving this warning:
../main.cpp:22:8: warning: ignoring packed attribute because of unpacked
non-POD field ‘wyde foo::two’ [enabled by default]
Should this decision be adjusted to take trivial types into account?
--
P.