https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69128
Bug ID: 69128 Summary: [4.9/5/6 Regression] OpenMP workshare problem with SUM() Product: gcc Version: 6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: anlauf at gmx dot de Target Milestone: --- Reported in https://gcc.gnu.org/ml/fortran/2015-12/msg00112.html % gfc-trunk workshare-sum.f90 -fopenmp workshare-sum.f90:16:0: !$omp parallel workshare Error: work-sharing region may not be closely nested inside of work-sharing, 'critical', 'ordered', 'master', explicit 'task' or 'taskloop' region The error shows up with 4.7/4.8/4.9/5/6. No error with 4.6. The error appears for SUM(), but not e.g. for MAXVAL(). The code is accepted by ifort, sunf95, crayftn. Testcase: % cat workshare-sum.f90 program test implicit none real, allocatable :: a(:,:), b(:) integer :: dim1, dim2, i,j dim1=10000 dim2=500 allocate(a(dim1,dim2),b(dim1)) call random_number(a) !$omp parallel do do i=1,dim1 b(i) = sum(a(i,:), dim=1) end do !$omp end parallel do !$omp parallel workshare ! b(:) = maxval(a(:,:), dim=2) ! No problem with maxval() b(:) = sum(a(:,:), dim=2) ! Failure with sum() !$omp end parallel workshare end program