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

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
If there's a way to do

void foo (int n, struct { int x[n]; } *s)
{
  s->x[1] = 0;
}

int main(int argc, char **argv)
{
  struct S { int x[argc]; } s;

  s.x[1] = 1;
  foo (argc, &s);
  if (s.x[1] != 0)
    __builtin_abort ();
  return 0;
}

in Ada we'd have a non-nested fn case as well.  The C FE currently
rightfully complains:

t.c:1:18: warning: anonymous struct declared inside parameter list will not be
visible outside of this definition or declaration
 void foo (int n, struct { int x[n]; } *s)
                  ^~~~~~
t.c: In function ‘main’:
t.c:11:14: warning: passing argument 2 of ‘foo’ from incompatible pointer type
-Wincompatible-pointer-types]
   foo (argc, &s);
              ^~
t.c:1:40: note: expected ‘<Ub390> *’ but argument is of type ‘struct S *’
 void foo (int n, struct { int x[n]; } *s)
                  ~~~~~~~~~~~~~~~~~~~~~~^

which means VL types cannot be passed across functions unless nested
(besides VLA types I guess).

Reply via email to