Hi,
On Nov 28, 2011, at 14:03 , Neil N. Carlson wrote:
>
> I'm not actually surprised that the argument expression
> was fully evaluated; that would be required if
> merge were a user-function. Do intrinsic functions
> have special rules in this regard?
No.
>
> That got me to wondering why this bit of code doesn't
> cause any problems with the other compilers we use,
> which do trap on fp exceptions by default. Poking
> around with the nag compiler, I've found that it
> compiles the merge to a loop that only evaluates those
> elements of the array expression that are used, and
> so never tries to do a 1.0/0.0. I'd guess that the
> other compilers are doing the same thing.
Yes.
>
> I actually prefer this behavior (in this case at least),
> but I'm suspicious that this may not be strictly kosher.
It isn't.
This has been discussed at length in J3/WG5 meetings.
The difficulty is that expression evaluation goes to the heart
of a compiler's optimizations. Thus, changes to the standard
in this area must be made carefully.
There was a proposal for f08 to add a "chooser" feature,
which would satisfy the don't-evaluate-this-yet desire.
But no one design emerged as clearly best, and there was a lack
of time and people to fully explore things.
IIRC, the two designs were a pseudo-function and a pseudo-operator.
Neither could be seen as clearly better than the other.
--
Cheers!
Dan Nagle
|