The following code gives an ICE in ifx 2023.0.0 20221201.
It seems to be essential that variable x is polymorphic.
Remark: this bug has been mentioned on fortran-lang.discourse.group, but I could not find it here, nor any short reproducer.
program string_slice type :: t character(len=:), allocatable :: cs end type t class(t), allocatable :: x allocate(t :: x) x%cs = 'abcdef123456' print *, first(x%cs(7:)) contains function first(cs) result(d) character(len=1) :: d character(len=*), intent(in) :: cs d = cs(1:1) end function first end program string_slice
I have now encountered a very similar problem. No ICE, but the produced code gives a wrong result.
The result of a concatenation 'x%cs // y%cs(lower:upper)' is computed (x and y of type(t) from above), but with the wrong section from y%cs. In fact, the section y%cs(1:upper-lower+1) is appended. The provided lower bound "lower" is ignored, the length of the section is correct.
Unfortunately I do not yet have a small reproducer for this problem. When I touch the routine where the y%cs character value is actually assigned, I run into the ICE mentioned above. The hopefully this is related.