Related articles |
---|
[7 earlier articles] |
Re: Number of compiler passes m.helvensteijn@gmail.com (Michiel) (2008-07-26) |
Re: Number of compiler passes gah@ugcs.caltech.edu (glen herrmannsfeldt) (2008-07-27) |
Re: Number of compiler passes gneuner2@comcast.net (George Neuner) (2008-07-28) |
Re: Number of compiler passes gneuner2@comcast.net (George Neuner) (2008-07-28) |
Re: Number of compiler passes gah@ugcs.caltech.edu (glen herrmannsfeldt) (2008-07-29) |
Re: Number of compiler passes gah@ugcs.caltech.edu (glen herrmannsfeldt) (2008-07-29) |
Re: Number of compiler passes m.helvensteijn@gmail.com (Michiel) (2008-07-29) |
Re: Number of compiler passes m.helvensteijn@gmail.com (Michiel) (2008-07-29) |
Re: Number of compiler passes barry.kelly@codegear.com (Barry Kelly) (2008-07-30) |
Re: Number of compiler passes gah@ugcs.caltech.edu (glen herrmannsfeldt) (2008-08-01) |
Re: Number of compiler passes gneuner2@comcast.net (George Neuner) (2008-08-03) |
Re: Number of compiler passes gneuner2@comcast.net (George Neuner) (2008-08-03) |
From: | Michiel <m.helvensteijn@gmail.com> |
Newsgroups: | comp.compilers |
Date: | Tue, 29 Jul 2008 18:00:08 +0200 |
Organization: | Wanadoo |
References: | 08-07-041 08-07-044 08-07-048 08-07-058 08-07-059 08-07-068 |
Keywords: | analysis, Fortran |
Posted-Date: | 01 Aug 2008 06:46:10 EDT |
glen herrmannsfeldt wrote:
> I believe for Fortran INTENT(OUT) dummy variables, you must
> write first, but you can then read the value just as any other
> variable. They are not write-only.
I thought about this. But there is no (easy) way at compile time to figure
out if a variable has actually been written to. Think of this example:
int f(out int a) {
if (rnd(0,10) > 5) {
a <- 5;
}
result <- a; // is this allowed?
}
Note:
* rnd returns a random number
* <- is the assignment operator
* the language has no return statement, but rather a result variable
> Among other reasons, Fortran allows either call by reference
> or call by value result (sometimes called copy-in copy-out).
> In the latter case, INTENT(OUT) might not do the copy in.
> It can also affect the way the optimizer works.
I believe the optimizer could do much with the guarantee that a variable
will never be read.
Anyway, there are ways around this, of course. Just assign to a local
variable first, so you can use the value again.
--
Michiel Helvensteijn
Return to the
comp.compilers page.
Search the
comp.compilers archives again.