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]

Re: structure members of packed structures


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



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