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

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Another, still undefined, but perhaps slightly less so, testcase is:
static int foo ();

int
bar (int n)
{
  struct S { char a[n]; } x;
  __builtin_memset (x.a, 0, n);
  return foo (n, x);
}

static inline int
foo (int n, struct T { char a[n]; } b)
{
  int r = 0, i;
  for (i = 0; i < n; i++)
    r += b.a[i];
  return r;
}

I wonder if the easiest fix isn't just to disable inlining if any of the
arguments has variable length.  The inliner seems to be clearly unprepared to
handle that.  VLAs when passed are passed as pointers to the elements, so it is
only about variable length structures or if some front-end would pass arrays as
arrays and not as pointers.

Reply via email to