[gfortran] Fix NULL reference types.

Paul Brook paul@codesourcery.com
Fri Aug 20 22:17:00 GMT 2004


On Friday 20 August 2004 23:07, Toon Moene wrote:
> Dale Johannesen wrote:
> > The language in F77 (15.9.3.2) is:
> > "If the actual argument is a constant ... the associated dummy
> > argument must not be redefined within the subprogram."
> > By itself, that is not totally clear; does that mean redefined
> > anywhere in the subprogram, or is redefinition a runtime property?
> >  From 15.8.4 it appears that "defined" and "redefined" are indeed
> > runtime properties, so this seems to be valid.
>
> The first call to sub1, in itself, is valid.  The subroutine shouldn't
> define b on a call that has a set to zero, because, after all, the body
> of the subroutine says:
>
> if (a > 0) b = log(a).
>
> The problem is the legality of the complete program.  In Fortran,
> there's only one instance of subroutine sub1.  Either it defines (sets)
> b or it doesn't.

What about

subroutine foo(x)
  call bar(x)
end subroutine

We must cannot assume that the actual argument associated with x is definable, 
however we must also assume that bar may redefine its argument. Only at 
runtime can we determine which of these is true.

Why shouldn't the same this apply to sections of code within a function (ie. 
if statements)?

> Perhaps the correct solution of *this* problem is to compile it as:
>
> subroutine sub1(a, b)
> real a, b, c
> if (a>0) then
>     c = log(a)
>     b = c
> endif
> end
>
> I don't think the current alias analysis - that ascertains that a and b
> don't point to overlapping storage, actually does this.

How is this different from the original example? The assignment to b is still 
conditional on the value of a.

Paul



More information about the Fortran mailing list