This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: structure members of packed structures
- From: Nathan Sidwell <nathan at codesourcery dot com>
- To: Nathan Sidwell <nathan at codesourcery dot com>
- Cc: Hans-Peter Nilsson <hp at bitrange dot com>, gcc at gcc dot gnu dot org, Mark Mitchell <mark at codesourcery dot com>, dalej at apple dot com
- Date: Tue, 15 Jul 2003 15:08:44 +0100
- Subject: Re: structure members of packed structures
- Organization: Codesourcery LLC
- References: <Pine.BSF.4.44.0307142207420.4585-100000@dair.pair.com> <3F13C008.9040906@codesourcery.com>
In C++, what about non-pods? Here is the problematic case,
struct A { int m; A (); };
struct __attribute__((packed)) B { char c; A a; };
Inside A::A, the this pointer will point to an unaligned object. I think
we should not pack B::a in this case, but issue a warning. We should pack
it if A itself is a packed type.
struct __attribute__((packed)) A { int m; A ();};
struct __attribute__((packed)) B { char c; A a;}; // ok
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
The voices in my head said this was stupid too
nathan@codesourcery.com :: http://www.planetfall.pwp.blueyonder.co.uk