[to fortran@ : Sorry if you see this twice, my first mail to the J3 list
was dropped because of the wrong sender address.]
Hi,
this is copied to both the J3 and the gfortran mailing list.
Consider the following procedure
real function radd_v1 (a,b,c,d) result(res)
real, value :: a, b, c, d
real :: tmp
tmp = a + b
tmp = tmp + c
res = tmp + d
end function radd_v1
Is a processor allowed to evaluate this like the function
real function radd_v2 (a,b,c,d) result(res)
real, value :: a, b, c, d
res = a + b + c + d
end function radd_v2
which can, according to 10.1.5.2.4 Evaluation of numeric intrinsic operations
be evaluated as if it had been written
real function radd_v3 (a,b,c,d) result(res)
real value :: a, b, c, d
res = (a + b) + (c + d)
end function radd_v3
or alternatively
real function radd_v4 (a,b,c,d) result(res)
real, value :: a, b, c, d
res = ((a + b) + c) + d
end function radd_v4
as a straightforward reading of radd_v1 might suggest? The results
between radd_v3 and radd_v4 might be different because, for an IEEE
system and depending on the input data, one might generate infinity and
the other not.
Comments?
Best regards
Thomas