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: g++.dg/ext/packed3.C


Jan Beulich wrote:
This test contains three invocations of Ref(), but only two of them are
considered ill. What I'd like to get an explanation for is why the third
(middle) instance is considered correct. After all, the u member of
Packed is packed, and hence all the members of Unpacked in that context
are, too. Namely, even if the object referenced by p is properly
aligned, p.u isn't and hence p.u.i isn't either.

I'm asking this because for *-*-netware*, which uses packed structures
by default, this test fails with an error message like the ones expected
on the other two calls to Ref().

Although Unpacked is a pod type, if it contained non-static member functions, those member functions would expect a this pointer that is correctly aligned. We have two options
1) don't pack fields of structure type
2) don't pack fields of non-pod or non-static member function containing structs


#2 means the alignment of your field can change, depending on whether the field's type contains a non-static member or not. C++ has no term for such a class.

#1) breaks GNU C compatibility, I think.

I'm not sure what the best answer is here.

If your system packs structs by default, you should not be getting the warning on any of the uses.

nathan

--
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
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]