Hi!
I was trying to iron out a wrinkle from a piece of code, when I stumbled
onto something which I find quite surprising, what I hold to be a
'reject valid' from GFortran: the 'reject valid' would belong here, the
other bit probably not, but if a kind soul could nevertheless enlighten
me, I would greatly appreciate it!
Take the following piece of code:
!
PROGRAM Test
!
IMPLICIT NONE
!
INTEGER :: Number, IO_Stat
! CHARACTER ( LEN = 250 ) :: String = "Hello world!"
CHARACTER ( LEN = 250 ) :: String = "/Hello world!"
!
! READ ( UNIT = TRIM(String), FMT = *, IOSTAT = IO_Stat ) Number
READ ( UNIT = String, FMT = *, IOSTAT = IO_Stat ) Number
WRITE ( UNIT = 6, FMT = * ) Number, IO_Stat
!
END PROGRAM Test
!
The obvious one first: "GNU Fortran (GCC) 4.3.0 20071026 (experimental)
[trunk revision 129646]" rejects "READ ( UNIT = TRIM(String)," with
READ ( UNIT = TRIM(String), FMT = *, IOSTAT = IO_Stat ) Number
1
Error: UNIT specification at (1) must be an INTEGER expression or a
CHARACTER variable
Is this warranted by the standard?, I would expect it to be fine: the
SGI, Lahey and Sun compilers seem happy with it... (for the record, the
Intel one doesn't either)
Now for the really weird part, if I remove the 'TRIM' to get over this,
I would expect an IO error to be raised, but I have yet to find a
compiler which does!