Friedrich Hertweck wrote:
>
> William F Mitchell schrieb:
>
> > I don't see why the optimization could
> > not be done, as long as the dummy argument is intent(in). With intent(in) the
> > compiler can assume the argument will not be changed. If the user overrules it
> > as you suggest, then the program is not standard conforming.
>
> I have not found any rule that prohibits this.
I think Malcolm covered this pretty well. If the argument has intent(in), then it
cannot be changed.
> > From the explicit interface, the compiler
> > does not know that the result is associated with the dummy argument, i.e.,
> > it does not know about the statement res2=>r2
>
> So I maintain my position that a good compiler should be able to check on these
> things.
> For instance a compiler does know if you invoke a subroutine, call sub(i*j+k), say,
> where
> the dummy argument is INTENT(OUT): it is a compile time error. When the module is
> compiled, the dummy argument of the function evidently gets a tag that it must not be
> an
> expression, and this tag is known in the interface.
I don't think it is necessarily a tag; intent(out) is simply part of the explicit
interface. But maybe that's just terminology, if you want to say that things like
"this argument must be real" or "this argument must be a rank 1 array" are "tags".
> A similar tag could be put on the
> argument
> of a if the function result pointsat it. So I still believe a compiler could do a
> lot more analysis.
Maybe it's possible -- I'll leave that call to the compiler writers. But it's
certainly not required. As far as I'm concerned, the compiler checks for argument
mismatches when there is an explicit interface, but I am not going to assume it
makes any other interprocedural analysis.
> You may of cause argue that incorrect programs may well be standard conforming
I don't think I'd argue in favor of that, true or not, and I don't think I've said
anything to indicate I would. I generally try to make my programs correct as well
as standard conforming :-)
Bill
--
William F. Mitchell
Mathematical and Computational Sciences Division
National Institute of Standards and Technology
[log in to unmask] http://math.nist.gov/~mitchell
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|