(j3.2006) Reallocation and dangling pointers

Tom Clune Thomas.L.Clune
Thu Apr 16 16:26:58 EDT 2015


On Apr 16, 2015, at 4:16 PM, Van Snyder <Van.Snyder at jpl.nasa.gov> wrote:

> Tom mentioned the case of an allocatable target being reallocated during
> intrinsic assignment to a whole array, thereby undefining pointers
> associated with it.  The same problem occurs if the variable is
> polymorphic, no matter whether it?s a scalar or an array.

Yes.

> 
> Processors could warn that this might happen, either at a declaration
> where a variable gets both the ALLOCATABLE and TARGET attributes, or at
> assignments where the reallocation might occur.
> 
> We could in principle revise the standard to turn off automatic
> reallocation if the variable has the TARGET attribute.  Do we favor
> array shape and dynamic type safety more, or do we favor pointer
> association status more?

This change would break ?many? existing codes.   

I think Malcolm?s points about the availability of workarounds settles this matter from my pov.   My job now becomes to convince all the vendors to implement the equivalent of -C=dangle.  :-)

- Tom



> 
> 
> _______________________________________________
> J3 mailing list
> J3 at mailman.j3-fortran.org
> http://mailman.j3-fortran.org/mailman/listinfo/j3

Thomas Clune, Ph. D. 				<Thomas.L.Clune at nasa.gov>
Head ASTG,Code 606
NASA GSFC		
MS 610.8 B33-C128
Greenbelt, MD 20771
301-286-4635









-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.j3-fortran.org/pipermail/j3/attachments/20150416/bbd820c3/attachment-0003.html 



More information about the J3 mailing list