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

--- Comment #13 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed #c11 testcase:
template <typename T>
struct S {
  T x;
  int y;
};

template <typename T>
T
bar (T x)
{
  return x;
}

void
foo (int x, int y)
{
  auto b = [&] { return x; };
  S <decltype (b)> c = { b, 42 };
  S <decltype (b)> d[2] = { { b, 42 }, { b, 42 } };
  auto *p = &d[1];
  #pragma omp target
  if (c.x () != 42 || d[y].x () != 42 || bar (p)->x () != 42)
    __builtin_abort ();
}

int
main ()
{
  foo (42, 0);
}

We ICE on this, in particular the bar (p)->x () part, while somehow handle
(unsure if correctly) the other cases.
So supposedly the short term workaround could simply handle the
COMPONENT_REFs/ARRAY_REFs around a var which is non-local and that is it for
now.  Even that will misbehave, e.g. if ARRAY_REF index is something defined
inside of the target region or not firstprivatized like here (say bar (y) as an
example or int z = y; d[z].x ()).

Reply via email to