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

2016-01-14 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69258

Richard Biener  changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |INVALID

--- Comment #6 from Richard Biener  ---
(In reply to jos...@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 *)) != 2)
abort ();
  if (bar ((struct Xflex *)) != 1)
abort ();
  return 0;
}

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

2016-01-13 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69258

--- Comment #1 from Richard Biener  ---
extern void abort (void);

struct Xflex { int n; int a[1]; };
struct Xspecific { int n; int a[7]; } x;

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 *)) != 2)
abort ();
  if (bar ((struct Xflex *)) != 1)
abort ();
  return 0;
}

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

2016-01-13 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69258

Richard Biener  changed:

   What|Removed |Added

 CC||jsm28 at gcc dot gnu.org

--- Comment #4 from Richard Biener  ---
Maybe undefined though (flex arrays are supposed to be used for allocated
storage and thus doesn't need to alias with static storage?)

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

2016-01-13 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69258

--- Comment #3 from Richard Biener  ---
Using

struct Xflex { int n; int a[]; };

doesn't fix it (as expected).

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

2016-01-13 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69258

Richard Biener  changed:

   What|Removed |Added

  Known to work||3.4.6
  Known to fail||4.0.4

--- Comment #2 from Richard Biener  ---
Seems for some reason 3.4.6 worked.

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

2016-01-13 Thread joseph at codesourcery dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69258

--- Comment #5 from joseph at codesourcery dot com  ---
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.)