> From [log in to unmask] Thu Feb 4 18:26:19 1999
> Adriaan Joubert said:
> > If you have allocation/deallocation in subroutines it is much safer to
> > use automatic arrays.
> There's no way to detect that allocation of automatic arrays failed, so
> you always get a crash in that case. For robustness, use allocatable.
> At least there, you have a STAT variable that you can check for failure,
> and then cope with it some other way, or terminate the program gracefully
> and with informative error messages.
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.
The C9x draft proposal includes VLA's, variable-length arrays, which are
like Fortran's auto. arrays. These share the same problem. We discussed
this problem in some detail in comp.std.c, and there is a proposal
afloat to remedy the matter -- but this cannot possibly make the cut
for this standard; maybe the next one.
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....
-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 ***********
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|