https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68673
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> --- E.g. #define N 2 int f1 (void) { int a[N], b[N], c[N]; int *ap = &a[0]; int *bp = &b[0]; int *cp = &c[0]; #pragma omp task shared (ap, bp, cp) for (unsigned int idx = 0; idx < N; idx++) { ap[idx] = 1; bp[idx] = 2; cp[idx] = ap[idx]; } return *cp; } int f2 (void) { int a[N], b[N], c[N]; int *ap = &a[0]; int *bp = &b[0]; int *cp = &c[0]; #pragma omp task // implicitly firstprivate (ap, bp, cp) for (unsigned int idx = 0; idx < N; idx++) { ap[idx] = 1; bp[idx] = 2; cp[idx] = ap[idx]; } return *cp; } struct A { A (); A (const A &); ~A (); int a; void foo (); }; int f3 (void) { int a[N], b[N], c[N]; int *ap = &a[0]; int *bp = &b[0]; int *cp = &c[0]; A d; #pragma omp task shared (ap, bp, cp) firstprivate (d) for (unsigned int idx = 0; idx < N; idx++) { d.foo (); ap[idx] = 1; bp[idx] = 2; cp[idx] = ap[idx]; } return *cp; } The first two GOMP_task calls have the same struct used on the caller and callee, while the third one has different structs (the caller's struct has a pointer to A in it, the callee's struct has A itself in it, the cpyfn callback is called to run the copy constructor and copy other pointers etc. from the caller's struct to the callee's struct. Note with the recent optimization I wrote, f1 is handled as firstprivate (ap, bp, cp) too, because none of those pointers are written in the task region.