https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111719
Bug ID: 111719 Summary: Omitting data-sharing attribute for function return value in OpenMP does not raise an error. Product: gcc Version: 13.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: pmblakely at googlemail dot com Target Milestone: --- In the following Fortran90 example: program prog contains function b(arr) implicit none integer :: i, xCells real(kind = 8) :: dx, a, dc, b, dt real(kind = 8), allocatable, dimension(:), intent(in) :: arr b = 1d300 dc = 1d300 !$OMP parallel do default(none) reduction(min:dt) firstprivate(xCells, dx, a) shared(arr) do i = 0, xCells a = arr(i) b = min(b, 1d0 / a) end do end function b end program prog the return value for function 'b' is the intended reduction value in the do-loop, but is not mentioned in the OpenMP reduction clause (dt is incorrectly mentioned instead). Due to the default(none) clause, this should be a compile-time error. However: gfortran test.f90 -o test -fopenmp compiles this without warnings or errors (versions 13.1.0, 8.4.0, 9.4.0, 11.2.0 and 12.1.0 all tested). If "b = min(b, 1d0 / a)" is replaced by "dc = min(dc, 1d0/a)" then gfortran gives: "Error: 'dc' not specified in enclosing ‘parallel’" I would expect this error to be generated in the original case as well. Note that the OpenMP standard at https://www.openmp.org/spec-html/5.2/openmpsu33.html does not give an implicitly determined data-sharing attribute for the function return value. Also the Intel Fortran ifort (2021.8.0) does raise the expected error on the above test-code.