https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111116
Bug ID: 111116 Summary: [OpenACC] Implicit mapping wrong for scalar Fortran pointers Product: gcc Version: 14.0 Status: UNCONFIRMED Keywords: openacc, wrong-code Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: burnus at gcc dot gnu.org CC: cltang at gcc dot gnu.org, tschwinge at gcc dot gnu.org Target Milestone: --- Longer example: https://gcc.gnu.org/pipermail/fortran/2023-August/059705.html The problem in the following program is that 'ptr' is a Fortran POINTER, i.e. an aggregate variable per the glossary (all quotes are from OpenACC 3.2). But it is treated as if it were a scalar. "Aggregate variables – a variable of any non-scalar datatype, including array or composite variables. In Fortran, this includes any variable with allocatable or pointer attribute and character variables." However, as the dump shows, the variable is 'firstprivate' (serial, parallel) or 'copy' (kernels). Expected: 'present' for 'default(present)' and otherwise 'copy': #pragma omp target oacc_parallel firstprivate(ptr) #pragma omp target oacc_parallel default(present) firstprivate(ptr) #pragma omp target oacc_serial firstprivate(ptr) #pragma omp target oacc_serial default(present) firstprivate(ptr) #pragma omp target oacc_kernels map(force_tofrom:*ptr [len: 4]) map(alloc:ptr [pointer assign, bias: 0]) #pragma omp target oacc_kernels default(present) map(force_tofrom:*ptr [len: 4]) map(alloc:ptr [pointer assign, bias: 0]) ------------ subroutine sub integer, pointer :: ptr allocate(ptr) ptr = 5 !$acc parallel ptr = 8 !$acc end parallel !$acc parallel default(present) ptr = 8 !$acc end parallel !$acc serial ptr = 8 !$acc end serial !$acc serial default(present) ptr = 8 !$acc end serial !$acc kernels ptr = 7 !$acc end kernels !$acc kernels default(present) ptr = 7 !$acc end kernels deallocate(ptr) end ------------ "2.6.2 Variables with Implicitly Determined Data Attributes" states: ... An aggregate variable will be treated as if it appears either: • In a present clause if there is a default(present) clause visible at the compute construct. • In a copy clause otherwise. A scalar variable will be treated as if it appears either: • In a copy clause if the compute construct is a kernels construct. • In a firstprivate clause otherwise. Note: Any default(none) clause visible at the compute construct applies to both aggregate and scalar variables. However, any default(present) clause visible at the compute construct applies only to aggregate variables. * * * Vaguely related: PR 90247 which is about pointers in a C program.