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

            Bug ID: 115193
           Summary: using indices with character type within a select type
                    causes ICE
           Product: gcc
           Version: 14.1.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ryan.mulhall at noaa dot gov
                CC: thomas.robinson at noaa dot gov, unassigned at gcc dot 
gnu.org
  Target Milestone: ---

This bug seems to be a regression from past versions, gfortran 10-13 worked
without error.

Bug #100860 describes a similar issue, but gfortran 14.1.0 generates an ICE
while the original issue had a seg fault.

I believe the error is coming from the usage of indices to get a substring from
a class(*) type.

I've simplified the test program from the original report to be more compact:


program test

  implicit none

  character (len=:), allocatable :: str

  str = "examplestring"
  call foo(str,13)

  contains

  subroutine foo(bar, strlen)
    class(*), intent (in)  :: bar
    integer,  intent (in)  :: strlen

    select type (bar)
    type is (character(*))
      print *, 'String is "', bar(1:strlen), '"' ! fails here 
    class default
      print *, "Not the right type"
    end select
  end subroutine

end program test

Reply via email to