This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [gfortran] Fix NULL reference types.


Paul Brook wrote:

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.

I'm pretty sure that, because you didn't specify an intent on foo(x)'s argument, you have to be prepared that x may be redefined, in this case by calling bar(x).


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

Well, perhaps you're right.


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.

The difference is that in this case we only set b to (the otherwise uninitialized) c in the branch of the if where it has a value.


Hence: if (a>0) then b has a useful value (namely, c=log(a))
       else b has no useful value, but won't be set, so there is no
       problem passing a constant for b.

--
Toon Moene - mailto:toon@moene.indiv.nluug.nl - phoneto: +31 346 214290
Saturnushof 14, 3738 XG  Maartensdijk, The Netherlands
Maintainer, GNU Fortran 77: http://gcc.gnu.org/onlinedocs/g77_news.html
A maintainer of GNU Fortran 95: http://gcc.gnu.org/fortran/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]