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

            Bug ID: 87239
           Summary: ICE in deferred-length string
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: juergen.reuter at desy dot de
  Target Milestone: ---

The following code posted on c.l.f. on Apr 28, 2018 leads to an ICE with
gfortran, but it seems this was never posted here:
$ gfortran alloc_string.f90
alloc_string.f90:24:0:

24 |   out = gettwo( inp )
   | 
internal compiler error: in gimplify_var_or_parm_decl, at gimplify.c:2697

with the following code:

!alloc_string.f90
module test
  implicit none
contains

  elemental function gettwo( s ) result( res )
    character(*), intent(in) :: s
    character(len(s)) :: res

    res = s( 1 : 2 )
  endfunction gettwo

endmodule test

program main
  use test
  implicit none
  character(10) :: inp( 5 )

  ! character(10), allocatable :: out(:) ! this works
  character(:), allocatable :: out(:) ! this is NG

  inp = [ 'aaa', 'bbb', 'ccc', 'ddd', 'eee' ]

  out = gettwo( inp )

  print *, out ! aa bb cc dd ee (with gfortran-7.3 + fixed-length out)
endprogram main

Reply via email to