https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128476
Bug ID: 128476
Summary: [OpenMP] Implicit 'private' for loop variables rejects
valid, bogus code with 'target teams map(...)'
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Keywords: diagnostic, rejects-valid
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: burnus at gcc dot gnu.org
Target Milestone: ---
Cf. https://github.com/OpenMP-Validation-and-Verification/OpenMP_VV/pull/919
!$omp target teams map(j)
!$omp loop
do j = 1, 2
end do
!$omp end loop
!$omp end target teams
end
This code currently gives:
Error: Symbol ājā present on multiple clauses at (1)
The reason is that an implicit 'private(j)' is added due to:
> 7.1.1 Variables Referenced in a Construct
> ...
> * Loop-iteration variables inside task-generating constructs are private in
> the innermost such construct that encloses the loop.
However, IMHO this only applies to 'teams' and not to 'target teams' - and the
problem occurs because it is added to the latter, clashing with 'map(j)'.
EXPECTED: The code is accepted but a warning is printed that the
implicit 'private' makes the 'map' clause pointless.
As we have eventually to support 'private( teams : j)', this could be added
once this feature is implemented.
For the test case discussed, either 'map(j)' or 'shared(j)' makes the code
sensible.