[J3] [EXTERNAL] Re: Changing address of an allocatable on assignment when shapes match

Van Snyder van.snyder at jpl.nasa.gov
Sat Aug 24 03:43:14 EDT 2019


On Sat, 2019-08-24 at 14:29 +0900, Malcolm Cohen via J3 wrote:
> The breakage would be if you moved the target, a pointer to that
> target would stop working, i.e. the semantics would be broken.
>  
> Unless, of course, one updates all the associated pointers when you
> move a target (like compacting garbage collectors do).

As Malcolm pointed out, the deallocation before the revised allocation
causes all associated pointers to become undefined. The reallocation is
fine and standard conforming, even if the <variable> has the TARGET
attribute. What's not allowed is using a formerly associated pointer
after it becomes undefined -- no matter how it became undefined.

There might be some ambiguity because the standard lists the conditions
under which the <variable> is reallocated during assignment, but it
doesn't say "and otherwise it shall not be reallocated." That seems to
be easier to remedy than messing with the relationship between the
TARGET attribute and an allocatable <variable> in an assignment
statement.

>  
> Cheers,
>  
> From: Vipul Parekh via J3 
> Sent: Saturday, August 24, 2019 12:14 PM
> To: General J3 interest list 
> Cc: Vipul Parekh 
> Subject: Re: [J3] [EXTERNAL] Re: Changing address of an allocatable on
> assignment when shapes match
>  
> I couldn't understand the statement, "In general, it would not be
> conforming to do the reallocation if the allocatable array has the
> TARGET attribute, as this would break the Fortran pointer association
> semantics" - can someone please point me to the relevant section(s)
> (and paragraph(s)) in the standard that might explain it for me?
> 
> Thanks,
> Vipul Parekh
> 
> 
> On Fri, Aug 23, 2019 at 9:16 PM Malcolm Cohen via J3
> <j3 at mailman.j3-fortran.org> wrote:
> >
> > We do say so! We state precisely when “reallocation” happens. It’s
> not called “reallocation” either; it is called “deallocating” followed
> by “allocating”.
> >
> > And “reallocation” is already in the reasons, seeing as how it is
> stated as “deallocation”, which is already in the reasons. ..
> 
> 
> 
> 
> Disclaimer
> 
> The Numerical Algorithms Group Ltd is a company registered in England
> and Wales with company number 1249803. The registered office is:
> Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.
> Please see our Privacy Notice for information on how we process
> personal data and for details of how to stop or limit communications
> from us.
> 
> This e-mail has been scanned for all viruses and malware, and may have
> been automatically archived by Mimecast Ltd, an innovator in Software
> as a Service (SaaS) for business.
> 
> 




More information about the J3 mailing list