[PR fortran/89077, patch] - ICE using * as len specifier for character parameter
Harald Anlauf
anlauf@gmx.de
Mon Feb 4 21:21:00 GMT 2019
On 02/04/19 22:07, Steve Kargl wrote:
> On Mon, Feb 04, 2019 at 09:55:39PM +0100, Harald Anlauf wrote:
>> I am still trying, but also wondering why such simple things as
>>
>> integer :: i
>> character(*), parameter :: s = 'abcdef'
>> character(1) :: t = transfer ([ s(1:1) ], 'x') ! no ICE
>> character(1) :: u = transfer ([(s(i:i),i=1,1)], 'x') ! ICE
>> print *, len (t), len (u) ! ICE happens when u is referenced
>> end
>>
>> are going down so different routes during simplification. :-(
>> Any hint is highly welcome!
>
> The best explanation I have is that gfortran sort of doesn't
> know how to handle implied-do-loops. Sometimes gfortran
> does what you expect, and sometimes you're off in the weeds
> trying to understand why 'i' is handled correctly.
The above example becomes even more confusing when replacing
character(1) :: t = transfer ([ s(1:1) ], 'x') ! no ICE
by
character(1), parameter :: t = transfer ([(s(i:i),i=1,1)], 'x') ! no ICE
If I understand this correctly, for the latter case the r.h.s. needs to
be a constant expression, while for the initialization it only needs to
be a specification expression. Hmmm.
Harald
More information about the Fortran
mailing list