Memory (de)allocation again
Richard E Maine
Richard.Maine@nasa.gov
Thu May 18 14:49:00 GMT 2006
On May 18, 2006, at 2:16 AM, François-Xavier Coudert wrote:
> In one of my runs, the ASSOCIATED returns .true., and the DEALLOCATE
> statement then exits with istat /= 0. I think that's a sign of a bug
> in gfortran, but I'm not sure: is that information enough to conclude?
That is absolutely not enough information to conclude such a thing.
Could be a bug in gfortran, but that is certainly nowhere near
sufficient information to know (and I didn't study the provided
debug data as it doesn't mean much to me without research). Indeed,
my first reaction is that it sounds typical of a quite common user
coding error.
When users ask this question (ok, not about the same program, but the
same general situation), it tends to make me extra suspicious of user-
code bugs, because to me the question illustrates that the user has
forgotten about (or never knew) a critical and fundamental issue
relating to pointers. If they have forgotten about that issue, odds
of their pointer-using code having bugs seems high.
The issue is, of course, that pointer association status can be
undefined and that it is illegal to even use the associated intrinsic
on a pointer with undefined association status. If code does that, it
is quite typical for the associated intrinsic to return bogus
results. Symptoms like getting a true value from associated, but then
being unable to deallocate or reference the pointer are very typical;
yes, I've seen variants of that question a lot.
Another possibility is that memory has gotten corrupted from any of
the usual suspects (exceeding dimension limits, argument list
mismatches, errors in using pointers, etc.).
--
Richard Maine | Good judgment comes from experience;
Richard.Maine@nasa.gov | experience comes from bad judgment.
| -- Mark Twain
More information about the Fortran
mailing list