https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113867
--- Comment #5 from Tobias Burnus <burnus at gcc dot gnu.org> --- For: int *q; #pragma omp target device(y5) map(q, q[:5]) GCC currently generates: map(tofrom:q [len: 8]) map(tofrom:*q.4_1 [len: 20]) map(attach:q [bias: 0]) Expected: 'alloc:' instead of 'attach:' or even: map(tofrom:*q [len: 20]) map(firstprivate:q [pointer assign, bias: 0]) In any case, the first 'tofrom' is pointless! NOTE: GCC 13 shows: error: 'q' appears both in data and map clauses * * * For #pragma omp target map(s.p[:5]) GCC should do: map(tofrom:s [len: 24][implicit]) map(tofrom:*_5 [len: 16]) map(attach:s.p [bias: 0]) But (regression!) it does: map(struct:s [len: 1]) map(alloc:s.p [len: 8]) map(tofrom:*_5 [len: 16]) map(attach:s.p [bias: 0]) Solution: --- a/gcc/gimplify.cc +++ b/gcc/gimplify.cc @@ -12381,3 +12381,4 @@ gimplify_scan_omp_clauses (tree *list_p, gimple_seq *pre_p, if (OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_ATTACH - || OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_DETACH) + || OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_DETACH + || OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_ATTACH_DETACH) break; However, unless I messed up, this will cause tons of ICE(segfault).