http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50564
--- Comment #5 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-10-09 16:00:41 UTC --- (In reply to comment #4) > So, the best method is to disable front-end optimization within > a forall loop. > > I assume the same holds for DO CONCURRENT. I think do concurrent is OK - here, the same as with a DO loop applies -- only the user has to guarantee that the loop will yield the same result independent of the execution order of the bounds. However, I think the current FE optimization might have problems with threadsafety. Assume: !$OMP parallel do default(share) do i = 1, 5 A(i) = 5*cos(B(i))+8*cos(B(i)) end do If one now transforms this into: !$OMP parallel do default(share) do i = 1, 5 tmp = cos(B(i)) A(i) = 5*tmp+8*tmp end do one has a problem as "tmp" is shared. Thus, one needs to make sure that all inserted temporary variables are thread private (DECL_THREAD_LOCAL_P).