https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80304
Thomas Koenig <tkoenig at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords|wrong-code |diagnostic
Target Milestone|7.0 |---
Summary|[7 Regression] |Warn about variable
|do-concurrent dosn't work |redefinition in
|well with gfortran 7. |do-concurrent
Severity|normal |enhancement
--- Comment #9 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
What you are doing is
DO CONCURRENT( i=0:1 ,j=0:1)
a = a + add(i,j,abs(i-j))
b = b + add2(i,j,abs(i-j))
END DO
This causes the variables a and b to be defined multiple
times in the loop.
In the standard, this is given in 8.1.6.7 of J3/10-007:
A variable that is referenced in an iteration shall either be previously
defined during that iteration, or
shall not be defined or become undefined during any other iteration. A variable
that is defined or becomes
undefined by more than one iteration becomes undefined when the loop
terminates.
Conceptually, when parallelizing, you cannot depend on a having
any specific value during the loop execution, so the program
might read a in one thread, have it changed by another thread,
then add the value to it and store it back, losing what
was done by the other thread.
You cannot do a sum like this with DO CONCURRENT. In OpenMP terms,
what you are attempting a reduction.
It would be nice to warn about this, though.