This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
RE: C++ 3.4.5 packed reference warning
- From: "Steven L. Zook" <SLZook at Qualstar dot com>
- To: "Nathan Sidwell" <nathan at codesourcery dot com>
- Cc: <gcc at gcc dot gnu dot org>
- Date: Wed, 7 Dec 2005 08:47:00 -0800
- Subject: RE: C++ 3.4.5 packed reference warning
I guess what I don't understand is why struct A isn't POD. A reference
to something is basically just a pointer. It has no alignment
restrictions that a pointer wouldn't.
-----Original Message-----
From: gcc-owner@gcc.gnu.org [mailto:gcc-owner@gcc.gnu.org] On Behalf Of
Nathan Sidwell
Sent: Wednesday, December 07, 2005 8:03 AM
To: Steven L. Zook
Cc: gcc@gcc.gnu.org
Subject: Re: C++ 3.4.5 packed reference warning
Steven L. Zook wrote:
> When I compile this using gcc rev 3.4.5 (m68k-elf):
>
> struct A { char B;
> unsigned char & C; } __attribute__((packed)); unsigned char
> D; A E = { 'F', D };
>
> I get:
>
> testpp.cpp:2: warning: ignoring packed attribute on unpacked non-POD
> field `unsigned char&A::C'
>
>
> sizeof( E ) == 6 (B, a byte of pad since m68k uses 16 bit alignment,
> and C).
>
> This construct compiled without warning under 3.3.3 and gave sizeof( E
> ) == 5.
>
> Is this behavior under 3.4.5 (both the warning and the ignoring of the
> packed attribute on the reference member) proper (justified,
> necessary, good)?
It is bad to pack non-pod structs, because of alignment assumptions of
member functions thereof. The checking code just checks the non-podness
of the type, as non-pod is a well defined term. This could be relaxed.
File a bug report if needed.
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery
LLC
nathan@codesourcery.com ::
http://www.planetfall.pwp.blueyonder.co.uk