Silverfrost Forums

Welcome to our forums

Array constructor issue

17 Dec 2007 2:40 #2511

In the following test, FTN95 seems to lose track of the fact that variable I is used as a ac-do-variable in the array constructor:

program init_bug implicit none

integer :: i character(11), parameter :: string='hello world'

! This compiles: character, parameter :: up_string(len (string)) = & (/ (string(i:i), i=1, len (string)) /)

! Yet this does not compile: integer, parameter :: bytes(len (string)) = & (/ (iachar (string(i:i)), i=1, len (string)) /)

print *, string print *, up_string print *, bytes

end program

FTN95 reports the following:

[FTN95/Win32 Ver. 5.10.0 Copyright (c) Silverfrost Ltd 1993-2007] 0012) integer, parameter :: bytes(len (string)) = & 0013) (/ (iachar (string(i:i)), i=1, len (string)) /) *** I is not a PARAMETER, so cannot appear in an initialisation expression

1 ERROR [salford_init_bug1.F90] - Compilation failed.

Playing around with the example a bit, I tried making I a PARAMETER. (This should not be needed, and may be illegal.) Depending on case FTN95 either generated bad code or simply crashed!

17 Dec 2007 2:54 #2513

Yes this looks like a bug.

For the moment you could remove the parameter attribute and do the assignment at via an executable statement at runtime.

17 Dec 2007 9:57 #2516

Thank you, Paul. Consider this a FYI, and not a critical need.

18 Dec 2007 7:09 #2517

For a work-around you could probably use '/ignore 538' on the command line in this context.

19 Dec 2007 7:33 #2521

This bug has now been fixed for the next release of FTN95.

Please login to reply.