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

            Bug ID: 97455
           Summary: ICE on invalid code (wrong pointer assignment) in
                    SELECT TYPE construct
           Product: gcc
           Version: 9.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: federico.perini at gmail dot com
  Target Milestone: ---

Created attachment 49383
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49383&action=edit
Test program

Hi, 

the following code produces an ICE Segmentation fault with gfortran 9.2.0: 

module m
      implicit none

      type, public :: t
      end type t
      type, public, extends(t) :: tt
      end type tt
      type, public :: container
          class(t), allocatable :: x(:)
      end type container

      contains

      subroutine polymorphic(self)
         type(container), intent(in) :: self
         ! select type (x => self%x(:)) ! Correct code
         select type (x => x(:)) ! This wrong code produces an ICE
              type is (t)
                   print *, 'type(t)'
              type is (tt)
                   print *, 'type(tt)'
              class default
                   print *, 'other'
          end select
      end subroutine polymorphic
end module m

program test_ice
      use m
      implicit none
      type(container) :: c
      call polymorphic(c)
end program test_ice

Some similar bug (#86551) was already reported, but this deals with the pointer
associating to itself so I thought to open a new one instead.

Reply via email to