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

            Bug ID: 113363
           Summary: ICE on ASSOCIATE and unlimited polymorphic function
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: anlauf at gcc dot gnu.org
  Target Milestone: ---

While discussing a patch for PR89645/99065, the following issue with
ASSOCIATE and unlimited polymorphic functions was found:

https://gcc.gnu.org/pipermail/fortran/2024-January/060098.html

program p
  implicit none
  class(*), allocatable :: x(:)
  x = foo()
  call prt (x)
  deallocate (x)            ! up to here all is fine...
  associate (var => foo())  ! <- crash here
    call prt (var)          ! <- or here
  end associate
contains
  function foo() result(res)
    class(*), allocatable :: res(:)
    res = [42]
  end function foo
  subroutine prt (x)
    class(*), intent(in) :: x(:)
    select type (x)
    type is (integer)
       print *, x
    class default
       stop 99
    end select
  end subroutine prt
end


This ICEs on current trunk for any of the indicated statements.

Reply via email to