This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] COMPONENT_REFs referring to non-aliasing structures don't alias - take 2
- From: Geoff Keating <geoffk at geoffk dot org>
- To: Dan Nicolaescu <dann at godzilla dot ICS dot UCI dot EDU>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: 11 Mar 2002 10:10:55 -0800
- Subject: Re: [patch] COMPONENT_REFs referring to non-aliasing structures don't alias - take 2
- References: <200203110805.aa03993@gremlin-relay.ics.uci.edu>
Dan Nicolaescu <dann@godzilla.ICS.UCI.EDU> writes:
> + /* Component refs that belong to structures that are known not to
> + alias, don't alias. */
Is this really correct?
For instance, I believe the following is allowed by the standard:
union u1 {
struct s1 {
int a;
int b;
} s1e;
struct s2 {
int a;
double d;
} s2e;
} u;
int foo(void)
{
struct s1 * s1p = &u.s1e;
struct s2 * s2p = &u.s2e;
s1p->a = 2;
return s2p->a;
}
because of the guarantees about common initial sequences of structures.
--
- Geoffrey Keating <geoffk@geoffk.org> <geoffk@redhat.com>