Hello world,

my query to the J3 list was met with resounding silence, for whatever
reason.  So, let me go again through the argument, this time with
some more standardese.

First, we have 5.3.5, which states

With the following exceptions, the effect of execution is as if the
executable constructs are executed in the order in which they appear
in the main program or subprogram until a STOP, ERROR STOP, RETURN,
or END statement is executed.

(where the exceptions are do, if, select ... end= etc, not of
interest in this case).

Plus, we have, as part of 10.1.5.2.4,

Once the interpretation of a numeric intrinsic operation is established, the
processor may evaluate any mathematically equivalent expression, provided that
the integrity of parentheses is not violated.

So consider

real function add4 (a,b,c,d)
  real, intent(in) :: a, b, c, d
  real :: t1, t2
  t1 = a + b
  t2 = t1 + c
  add4 = t2 + d
end function add4

So the compiler has to behave as if it evaluated the assignment
to t1 before anything else.  This is not consistent with reassociating
the expressions to

  add4 = a + b + c + d

and the grouping them as if the user had written

  t1 = a + b
  t2 = c + d
  add4 = t1 + t2

because that would violate 5.3.5 in case where the result
is different (e.g. an infinity where otherwise none would occur).

That should settle it.

Best regards

        Thomas


Reply via email to