This is the mail archive of the gcc-bugs@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]

[Bug middle-end/69258] Flexible arrays break TBAA


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69258

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to joseph@codesourcery.com from comment #5)
> I don't see a need for these different structures to be able to alias.  
> (Flexible array members do need to be able to alias static storage, in the 
> case where that static storage was declared with the structure type with 
> the flexible array member and the GNU C extension of initializing such 
> flexible array members was used.)

Ok, that works.  Phew.  Not sure if it is a solution for the Fortran FE
issue which wants to construct Xflex with a specific size on the stack
(it's the array descriptor with a known dimensionality).  I remember that
GNU C extension poses some interesting effects on the ME (inconsistent
TYPE_SIZE / DECL_SIZE at least).

extern void abort (void);

struct Xflex { int n; int a[]; };
struct Xflex x = { 1, { 1, 2, 3, 4, 5, 6, 7 } };

int __attribute__((noinline,noclone))
foo (struct Xflex *f)
{
  x.a[6] = 1;
  f->a[6] = 2;
  return x.a[6];
}

int __attribute__((noinline,noclone))
bar (struct Xflex *f)
{
  f->a[6] = 2;
  x.a[6] = 1;
  return f->a[6];
}

int main()
{
  if (foo ((struct Xflex *)&x) != 2)
    abort ();
  if (bar ((struct Xflex *)&x) != 1)
    abort ();
  return 0;
}

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