structure members of packed structures

Nathan Sidwell nathan@codesourcery.com
Tue Jul 15 14:34:00 GMT 2003


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




More information about the Gcc mailing list