On Tue, 2017-04-25 at 12:53 +0200, Richard Biener wrote:
> > int foo() {
> > int i,j;
> > for (i = 0; i < m; i++) {
> > a->o[i] = sizeof(*a);
> > b = ((struct r *)(((char *)a) + a->o[a->n]));
> > for (j = 0; j < 10; j++) {
> > b->slot[j].b = 0;
> in case b->slot[j].b aliases a->o[i] or a->o[a->n]
> you invoke undefined behavior becuase you violate
> strict aliasing rules. I don't know why there's a
> difference between -DFLEX and -UFLEX but your
> code is buggy even if it works in one case.
>
> Richard.
Should this work if I use -fno-strict-alias? Even with that option I
get different code with a zero-sized array vs. a flexible array.
I have a patch to get_ref_base_and_extent that changes the behaviour
for zero-length arrays and I will submit it after I have tested it.
Steve Ellcey
[email protected]