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

            Bug ID: 89077
           Summary: ICE using * as len specifier for character parameter
           Product: gcc
           Version: 8.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rrodrigues at poli dot ufrj.br
  Target Milestone: ---

I am getting an Internal Compiler Error when I use assumed character length (*)
in a parameter declaration, when using character substring (apparently,
compiler fails to determine the character length and crashes).



program test
  implicit none
  integer :: i

  ! assumed character length works normally here
  character(*), parameter :: str = 'abcdef'

  ! also works, with intrinsic char inside transfer
  character(*), parameter :: str1 = transfer([(char(64+i), i=1,len(str))], str)

  ! crashes with ICE here, with character substring inside transfer
  character(*), parameter :: str2 = transfer([(str(i:i), i=1,len(str))], str)

  ! it works when the type is specified in array constructor
  character(*), parameter :: str3 = transfer([character :: (str(i:i),
i=1,len(str))], str)

  ! also works, without assumed character length
  character(len(str)), parameter :: str4 = transfer([(str(i:i), i=1,len(str))],
str)

  print *, str, len(str)       ! 'abcdef', 6
  print *, str1, len(str1)     ! 'ABCDEF', 6
  ! print *, str2, len(str2)   ! should output 'abcdef', 6, but crashes
  print *, str3, len(str3)     ! 'abcdef', 6
  print *, str4, len(str4)     ! 'abcdef', 6
end

Reply via email to