Tom Clune asked:
[whether subscript out of range may be diagnosed as an error at compile time]
My own view is that the code is not conforming.
Given
REAL x(10)
I think that
... x(20000) ...
is no more conforming than say, given IEEE single-precision reals, that
1.0E+200 is conforming.
I doubt whether you'll find many compilers to accept the latter.
There are also other "more interesting" test programs vis-a-vis the subscript
out of range question. If we simplify the first test program to
PROGRAM p0
INTEGER :: x(1) = 0
IF (.FALSE.) PRINT *,x(200000)
END
Then many compilers accept this without diagnosis - with most of them not
even a warning.
Several compilers diagnose it as an error (NAG is not the only one).
Putting the PARAMETER attribute onto the array, we get the next program:
PROGRAM p1
INTEGER,PARAMETER :: x(1) = 1
IF (.FALSE.) PRINT *,x(200000)
END
This gets rejected by quite a few compilers (not all).
Another interesting program (particularly w.r.t. compilers that accept P1):
PROGRAM p2
INTEGER,PARAMETER :: k(1) = KIND(0.0)
REAL(KIND=k(200000)) :: x
x = 3
PRINT *,x
END
With the two compilers I had access to which accepted P1, both diagnosed P2
as being in error - though one of the diagnoses was "Segmentation fault"
(of the compiler).
Anyway, as I said, my own view is that all of these are non-conforming - but
you can only get a definitive answer by asking the standards committee.
There are simple conversions which would make the user's code conforming, so
in practice this does not seem terribly problematic to me anyway.
Cheers,
--
...........................Malcolm Cohen, NAG Ltd., Oxford, U.K.
([log in to unmask])
_____________________________________________________________________
This message has been checked for all known viruses by Star Internet delivered
through the MessageLabs Virus Control Centre. For further information visit
http://www.star.net.uk/stats.asp
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|