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

--- Comment #5 from Martin Uecker <muecker at gwdg dot de> ---
It works (and is required to work) for other types, e.g.

[[gnu::noinline,gnu::noipa]]
int foo(void *p, void *q)
{
        int n = 5;
        int (*p2)[n] = p;
        (*p2)[0] = 1;
        bar(q);
        return (*p2)[0];
}

void bar(void* q)
{       
        int n = 5;
        int (*q2)[n] = q;
        (*q2)[0] = 2;
}

One could argue that there is a weaker requirement for having an object of type
int[n] present than for struct { int x[n]; } because we do not access the array
directly but it decays to a pointer. (but then, other languages have array
assignment, so why does the middle-end care about this C peculiarity?) 

There is also no indication in documentation that structs with variable size
follow different rules than conventional structs.   So my preference would be
to fix this somehow.  Otherwise we should document this as a limitation.

Reply via email to