(j3.2006) ASSOCIATE and selectors

Steve Lionel steve
Mon Feb 20 11:19:54 EST 2017


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.j3-fortran.org/pipermail/j3/attachments/20170220/c972bd7c/attachment.html 



More information about the J3 mailing list