(j3.2006) ASSOCIATE and selectors

Van Snyder van.snyder
Mon Feb 20 14:48:32 EST 2017


I think this question came up earlier and we said the answer was that it
is not permitted.

On Mon, 2017-02-20 at 11:19 -0500, Steve Lionel wrote:
> A user presented an interesting program:
> 
> program Test
>    implicit none
>    type D
>       integer x
>    end type
>    type(D) array(1)
>    
>    array%x = 0
>    associate(a => array(1), b => a%x)
>       b = 9
>    end associate
>    print *, array(1)%x
>    pause
> end 
> 
> Intel Fortran allows the ASSOCIATE statement, associating B with the
> associate name A listed earlier in the same ASSOCIATE. I think this is
> wrong, but wanted to check to see if my reasoning is correct.
> 
> 17-007 says:
>         11.1.3.2 Execution of the ASSOCIATE construct
>         
>         Execution of an ASSOCIATE construct causes evaluation of every
>         expression within every selector that is a variable designator
>         and evaluation of every other selector, followed by execution
>         of its block. During execution of that block each associate
>         name identifies an entity which is associated (19.5.1.6) with
>         the corresponding selector.
> Note the sequence of events here. First, all of the selectors are
> evaluated, and only once the block begins executing does the construct
> association occur. If my interpretation is correct, it is wrong to
> treat an associate name listed earlier in the same ASSOCIATE as a
> variable that can be used in a selector.
> 
> Is my reasoning valid?
> 
> Steve
> _______________________________________________
> J3 mailing list
> J3 at mailman.j3-fortran.org
> http://mailman.j3-fortran.org/mailman/listinfo/j3





More information about the J3 mailing list