[Bug fortran/97977] New: Fortran deferred length strings incompatible with OMP

poorasmith at protonmail dot com gcc-bugzilla@gcc.gnu.org
Wed Nov 25 02:29:42 GMT 2020


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97977

            Bug ID: 97977
           Summary: Fortran deferred length strings incompatible with OMP
           Product: gcc
           Version: 7.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: poorasmith at protonmail dot com
  Target Milestone: ---

gfortran does not correctly handle deferred length strings in OMP loops. 
Minimal example program:

program test_OMPStr
  implicit none

  integer :: indx
  character(len=:), allocatable :: string1, string2

  !$omp parallel do default(none) &
  !$omp private(indx, string1, string2) &
  !$omp num_threads(2)
  do indx = 1, 50000
    string1 = ''
    string2 = ''
    string1 = 'abc'
    string2 = 'abc'
    if (string1 .ne. string2) then
      write(*,*) 'string mismatch on indx', indx
      stop
    end if
  end do
  !$omp end parallel do
end program test_OMPStr

This program will stop at a pseudo random index.  If num_threads(1) is used the
program works as expected.  If fixed length strings are used the program works
as expected.


More information about the Gcc-bugs mailing list