I've always thought:
When a program contains a statement that can be illegal only at run-time,
and that statement is never executed, the program is standard conforming.
Hasn't there ever been an INTERP in this area?
The question is how to decide whether a program is standard conforming, and
I think you can't always tell by looking. -- It's a lot like the "halting
problem:" Turing or Godel or somebody proved that it's logically and
inherently impossible to write a text analyzer (nowadays you would say a
syntax analyzer) that can look at ANY program and always tell "in advance"
whether it will halt or not.
I think "intent in" is a bit different, because it is SUPPOSED to be a
declaration about the syntactic usage of the argument, not about how it
might be used at run time. So constraints were added to pin this down.
= Loren P Meissner
-----Original Message-----
From: [log in to unmask]
[mailto:[log in to unmask]] On Behalf Of Richard Maine
Sent: Monday, November 06, 2000 3:46 PM
To: [log in to unmask]
Cc: [log in to unmask]; [log in to unmask]
Subject: Standards question
[...]
Umm. A bit subtle. The lines would be illegal if you ever executed
them, but you don't. The question is not whether it is legal to make
an out-of-bounds reference (that's not legal), but whether this even
*is* a reference until it is executed.
I might go so far as to say that the question relates to what the
definition of "is" is. :-)
The above citation appears to be the pertinent part of the standard,
but it's a bit tricky to interpret here. In general, a subscript is
an expression, the value of which may not be known until it is
evaluated at run-time. So the cited restriction pretty much has to be
a run-time restriction.
I conclude that the code is technically standard-conforming....I
think. But its subtle. I was hoping that someone else would
answer this first so that I wouldn't have to post an answer that
I had this much uncertainly about...I'm now waiting for someone to
show that I'm wrong.
You didn't ask for opinions on the style, so I won't offer any. But
I'll bet there is more than one compiler that will reject it. The
compiler probably figures it is being "helpful" in rejecting it at
compile time instead of letting the "obvious bug" hide until run-time.
I will note that there was a vaguely similar interpretation question
about whether it was legal to do things like
...
real, intent(in) :: x
...
if (.false.) x = 1.0
That one got resolved by adding syntax constraints against X even
appearing in a context like that, regardless of whether or not it
actually got executed. But that solution was specific to intent(in);
it doesn't generalize to other things that would be illegal if they
got executed.
--
Richard Maine
[log in to unmask]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|