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

            Bug ID: 128678
           Summary: Failure with !$omp parallel do simd on valid fortran
           Product: gcc
           Version: 16.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jvdelisle at gcc dot gnu.org
  Target Milestone: ---

The following reproducer fails with:

gfortran -fopenmp -c omp-simd-local-alloc-comp-ctor-ice.f90
gfortran -fopenmp -O2 -c omp-simd-local-alloc-comp-ctor-ice.f90
gfortran -fopenmp-simd -c omp-simd-local-alloc-comp-ctor-ice.f90

The simd is what triggers it; with plain !$omp parallel do it compiles fine.

module mc2
  implicit none
  type t
    real, allocatable :: v(:)
  end type
  type pair
    type(t) :: i, o
  end type
  type batch
    type(pair), allocatable :: p(:)
  end type
contains
  elemental function mkpair (i, o) result (r)
    type(t), intent(in) :: i, o
    type(pair) :: r
    r%i = i
    r%o = o
  end function
  pure function mkbatch (p) result (r)
    type(pair), intent(in) :: p(:)
    type(batch) :: r
    r%p = p
  end function
end module
program p2
  use mc2
  implicit none
  type(t) :: a(4, 3)
  type(batch) :: b(3)
  integer :: i, j
  do j = 1, 3
    do i = 1, 4
      a(i,j) = t([real(i+j)])
    end do
  end do
  !$omp parallel do simd
  do j = 1, 3
    b(j) = mkbatch (mkpair (a(:,j), a(:,j)))
  end do
  if (b(3)%p(4)%o%v(1) /= 7.0) stop 1
  print *, 'ok'
end program

Reply via email to