This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

__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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]