This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: C++ aliasing rules
- From: Jason Merrill <jason at redhat dot com>
- To: Dan Nicolaescu <dann at godzilla dot ICS dot UCI dot EDU>
- Cc: libstdc++ at gcc dot gnu dot org, gcc at gcc dot gnu dot org
- Date: Tue, 23 Apr 2002 10:43:27 +0100
- Subject: Re: C++ aliasing rules
- References: <200204031103.aa15838@gremlin-relay.ics.uci.edu>
>>>>> "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