On Mon, Jan 03, 2022 at 10:15:26PM +0800, Chung-Lin Tang wrote: > This issue was triggered after the patch extending syntax for component access > in map clauses > (https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=0ab29cf0bb68960c) > > In gimplify_scan_omp_clauses, the case for handling indirect accesses (which > creates > firstprivate ptr and zero-length array section map for such decls) was > erroneously > went into for non-pointer cases (here being the base struct decl), so added > the > appropriate checks there. > > Added new testcase is a compile only test for the ICE. The original omptests > t-partial-struct > test actually should not execute correctly, because for map(t.s->a[:N]), > map(t.s[:1]) > is not implicitly mapped, thus the entire offloaded access does not work as > is. > (fixing that omptests test is out of scope here) > > Tested without regressions, okay for trunk? > > Thanks, > Chung-Lin > > 2022-01-03 Chung-Lin Tang <clt...@codesourcery.com> > > gcc/ChangeLog: > > PR middle-end/103642 > * gimplify.c (gimplify_scan_omp_clauses): Do not do indir_p handling > for non-pointer or non-reference-to-pointer cases. > > gcc/testsuite/ChangeLog: > > * c-c++-common/gomp/pr103642.c: New test.
Ok, with a small nit: > +int main (void) > +{ > + T t; > + t.s = (S *) malloc (sizeof (S)); > + t.s->a = (int *) malloc (sizeof(int) * N); > + > + #pragma omp target map(from: t.s->a[:N]) > + { > + t.s->a[0] = 1; > + } Please free the pointers afterwards. Jakub