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: C++ aliasing rules


>>>>> "Dan" == Dan Nicolaescu <dann@godzilla.ICS.UCI.EDU> writes:

> struct first  {  int i; char a;  int f1;  char f2; double d;};
> struct second {  char b;  int f2;  int f3;};

> can it be assumed that given that "first" and "second" are
> incompatible then ps1.f1 and ps2.f2 don't alias

I'm not sure.  I suppose it depends on whether you consider ps1.f1 to be an
object for the purposes of [basic.lval], which says that an object can be
referenced through an lvalue of a class type which contains a member of
that object's type.  So since ps1.f1 is an int, and struct second contains
an int, the access can alias.

If we think that [basic.lval] only means to talk about complete objects,
then the access can't alias.

I'm not sure what the intent is, but from a strict reading I tend towards
the first interpretation; according to [intro.object] sub-objects are
objects, too.

Jason


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