> From: Alvaro Fernandez <[log in to unmask]>
> > and Peter Shenkin said:
> >
> > /In fact, automatic arrays are far more *convenient*, but far less *safe*,
> > /since, as Van said, there's no way to detect an allocation failure
> > /(usually a stack overflow) in this case. I know -- I've been there.
> >
>
> I agree. They also are more descriptive - i.e. it is clear from the start what
> the size
> of the array depends on.
...
> > /I've also raised the issue in this forum and in comp.lang.fortran,
> > /but don't detect any great enthusiasm for finding a solution. I
> > /suspect that not enough people use automatics yet for the full
> > /dimensions of the difficulties to be apparent. But watch out....
>
> I would say that unless you are writing production code which will be used
> widely by less-knowledgeable people, it won't matter.
Yup. But I write production code that will be used widely by less-
knowledgeable people, some of whom have small-memory machines.
Another aspect of the problem is that typically when auto allocation
fails, you get a SEGV. This is indistinguishable from a SETV caused
by other means -- such as dereferencing a NULL pointer. So the amount
of developer time that is wasted on examining user bug reports can be
huge, even if it does turn out, every time, that the problem is due
to auto allocation failure. And, of course, the user's problem might
not be easily reproducible, since his machine configuration will
typically differ from that of the developer's.
The more I think about it, the more I think I should tear f90 automatics
out of my code altogether and ALLOCATE everything.
Finally, I just got email from Richard Shapiro, a compiler developer
at SGI. In response to a request of mine, he has added a compiler feature
to SGI's f90 which should go at least some way toward solving the
problem:
> From [log in to unmask] Fri Feb 5 10:55:07 1999
> You will be happy to know that in Fortran 90 v7.3 (about to go to Beta) we
> have added an option to force allocations larger than a certain size (both
> for AUTOMATIC arrays and compiler generated temps) to go on the heap
> instead of the stack.
This feature originated in Cray's f90.
-P.
*** "Freedom's just another word for nothing left to lose." (B. Yeltsin)***
*********** Peter S. Shenkin; Schrodinger, Inc.; (201)433-2014 ************
*********** [log in to unmask]; http://www.schrodinger.com ***********
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|