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

            Bug ID: 87980
           Summary: ICE in gfc_conv_descriptor_data_get, at
                    fortran/trans-array.c for assignment on polymorphic
                    variable
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: juergen.reuter at desy dot de
  Target Milestone: ---

Created attachment 44987
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44987&action=edit
Reproducer for the ICE

The following code using assignment on polymorphic variables yields an ICE in 
gfc_conv_descriptor_data_get, at fortran/trans-array.c:145 with the actual
trunk (r266011). This feature was not supported in gfortran 5 and 6 and gives
an ICE in gfortran 7/8/9:
gfortran  -c quantum_numbers.f90
quantum_numbers.f90:35:0:

   35 |        if (present (col))  call qns%qn(i)%set (col=col(i))
      | 
internal compiler error: in gfc_conv_descriptor_data_get, at
fortran/trans-array.c:145
For us, this is lower priority as the problem occurs in an experimental branch
of our development. 
This is the code triggering the ICE (also attached): 
module quantum_numbers
  implicit none
  type, abstract :: col_t
  end type col_t

  type :: qn_t
     private
     class(col_t), allocatable :: c
   contains
     procedure :: set => qn_set
  end type qn_t

  type :: qn_string_t
     private
     integer :: length = 0
     type(qn_t), dimension(:), allocatable :: qn
  end type qn_string_t

contains
  impure elemental subroutine qn_set (qn, col)
    class(qn_t), intent(inout) :: qn
    class(col_t), intent(in), optional :: col
    if (present (col)) then
       qn%c = col
    end if
  end subroutine qn_set

  subroutine qn_string_set (qns, col)
    class(qn_string_t), intent(inout) :: qns
    class(col_t), dimension(:), intent(in), optional :: col
    integer :: i
    do i = 1, qns%length
       if (present (col))  call qns%qn(i)%set (col=col(i))
    end do
  end subroutine qn_string_set

end module quantum_numbers

Reply via email to