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

--- Comment #13 from Richard Biener <rguenth at gcc dot gnu.org> ---
Note that the cast doesn't help in itself (but for the warning) as Jakub
notices.
The deeper issue is type-based aliasing here.  IMHO libgfortran would need to
use

struct A { float *base_addr; size_t offset; long dtype; struct D dim[1]; }
*desc;

aka a pointer to a descriptor with flexible array member.  Which I hope ends
up aliasing with one with a different size.  Well, we treat 'dim' as flexible
array member in any case but I'm not aware of any code in alias.c that makes
this work.

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

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

returns 2 with -fstrict-aliasing :(

Thus even the proposed fix won't end up working.

Reply via email to