View previous topic :: View next topic |
Author |
Message |
wws
Joined: 25 Oct 2007 Posts: 7 Location: California
|
Posted: Mon Dec 17, 2007 3:40 pm Post subject: Array constructor issue |
|
|
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! |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7926 Location: Salford, UK
|
Posted: Mon Dec 17, 2007 3:54 pm Post subject: |
|
|
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. |
|
Back to top |
|
|
wws
Joined: 25 Oct 2007 Posts: 7 Location: California
|
Posted: Mon Dec 17, 2007 10:57 pm Post subject: |
|
|
Thank you, Paul. Consider this a FYI, and not a critical need. |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7926 Location: Salford, UK
|
Posted: Tue Dec 18, 2007 8:09 am Post subject: |
|
|
For a work-around you could probably use "/ignore 538" on the command line in this context. |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7926 Location: Salford, UK
|
Posted: Wed Dec 19, 2007 8:33 am Post subject: |
|
|
This bug has now been fixed for the next release of FTN95. |
|
Back to top |
|
|
|