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

--- Comment #3 from Jürgen Reuter <juergen.reuter at desy dot de> ---
Oops, sorry, I had to hurry and closed the laptop. I didn't think that the
issue got already submitted. Here is the reproducer.

gfortran -c state_matrices.f90 
state_matrices.f90:76:23:

   76 |     t2 = t3_get_t2 (qn)
      |                       1
internal compiler error: in gfc_is_nodesc_array, at fortran/trans-types.cc:1408


module m
  implicit none
  private

  type, abstract :: t1_t
     private
   contains
     generic :: assignment(=) => assign
     procedure (t1_assign), deferred :: assign
  end type t1_t

  type, extends (t1_t) :: t2_t
     private
     integer :: f = 0
   contains
     procedure :: assign => t2_assign
  end type t2_t  
  type :: t3_t
     private
     type(t2_t) :: f
   contains
     procedure :: get_t2 => t3_get_t2
  end type t3_t

  type :: s_iterator_t
     private
     integer :: depth = 0
   contains
     generic :: get_t2 => get_t2_single
     procedure :: get_t2_single => s_iterator_get_t2_single
     generic :: extract_t2 => extract_t2_multi
     procedure :: extract_t2_multi => s_iterator_extract_t2_multi
  end type s_iterator_t

  abstract interface
     subroutine t1_assign (q, q2)
       import
       class(t1_t), intent(inout) :: q
       class(t1_t), intent(in) :: q2
     end subroutine t1_assign
  end interface

  interface
    module subroutine t2_assign (q, q2)
      class(t2_t), intent(inout) :: q
      class(t1_t), intent(in) :: q2
    end subroutine t2_assign
  end interface

  interface assignment(=)
     module procedure t3_assign
  end interface assignment(=)

  interface
    impure elemental module function t3_get_t2 (qn) result (t2)
      type(t2_t) :: t2
      class(t3_t), intent(in) :: qn
    end function t3_get_t2
    module subroutine t3_assign (t1_out, t1_in)
      type(t3_t), intent(out) :: t1_out
      type(t3_t), intent(in) :: t1_in
    end subroutine t3_assign
  end interface
contains

  function s_iterator_get_t2_single (it, k) result (t2)
    class(s_iterator_t), intent(in) :: it
    integer, intent(in) :: k
    type(t2_t) :: t2
  end function s_iterator_get_t2_single

  subroutine s_iterator_extract_t2_multi (it, t2)
    class(s_iterator_t), intent(in) :: it
    type(t2_t), dimension(:), intent(out) :: t2
    type(t3_t), dimension(size(t2)) :: qn
    t2 = t3_get_t2 (qn)
  end subroutine s_iterator_extract_t2_multi

end module m

Reply via email to