https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114282
Bug ID: 114282 Summary: [OpenMP] Implicit mapping of function/procedure pointers should use 'firstprivate' Product: gcc Version: 14.0 Status: UNCONFIRMED Keywords: missed-optimization, openmp Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: burnus at gcc dot gnu.org Target Milestone: --- For C/C++ function pointers and Fortran dummy procedures / procedure pointers, the assumption is that pointer is either pointing to the desired function or it has the address of a function on the initial device with 'declare target indirect'. GCC produces for implicit mapping: map(alloc:MEM[(char *)g] [len: 0]) map(firstprivate:g [pointer assign, bias: 0]) But a simple map(firstprivate:g) would do here. Likewise for an explicit map, where there is also no need for a pointer assignment. NOTE: For Fortran, it might be that explicit 'map' clauses will get disallowed per pending OpenMP specification Issue #3823, which is tracked elsewhere. Trivial testcases (for more complex, see 'indirect' testcases inside GCC or just add an explicit 'map' clause yourself): void f(){ void (*g)(); #pragma omp target g(); } subroutine f(g) procedure(), pointer :: g !$omp target map(g) call g() !$omp end target end