Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28861 Discussions

ICE in ifx with array slice of deferred length character variable

martinmath
New Contributor II
496 Views

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

 

0 Kudos
2 Replies
martinmath
New Contributor II
455 Views

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.

 

0 Kudos
Barbara_P_Intel
Employee
436 Views

Good news! The ICE is gone in an internal version of ifx. The version with the fix is planned for release in the spring.



0 Kudos
Reply