Hi Andre and Mikael,

The associate block is added *after* the associate statement is matched and
the associate_names added to the parent namespace; see
parse.cc(parse_associate).

nagfor and flang-new both behave in the same way as gfortran. So ifort and
ifx are the odd ones out.

In F2018 and F2013, the scope of the selector is clear enough:
19.4 Statement and construct entities
...
9 The associate names of an ASSOCIATE construct have the scope of the
block. ......

Then,
19.5.1.6 Construct association
...
3 If the selector is a variable other than an array section having a vector
subscript, the association is with the data object specified by the
selector; otherwise, the association is with the value of the selector
expression, *which is evaluated prior to execution of the block.*

Given this and Mikael's observation, "that the names are not
defined/associated during the evaluation of selectors", I conclude that
gfortran has the correct behaviour.

As I understand it, the associate construct was intended to provide a
convenient way of representing arbitrary expressions from the parent scope
and so I wouldn't describe the behaviour as odd. It is what it is :-)

Best regards

Paul

Reply via email to