This is the mail archive of the gcc-patches@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: [patch] COMPONENT_REFs referring to non-aliasing structures don't alias - take 2


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>


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