[J3] Question on overflow and run-time detection of infinity?

Bill Long longb at cray.com
Tue Nov 27 15:24:08 EST 2018


> On Nov 27, 2018, at 11:43 AM, Van Snyder via J3 <j3 at mailman.j3-fortran.org> wrote:
> 
> On Tue, 2018-11-27 at 17:33 +0000, Bill Long wrote:
>>> Since it's OK for a processor to supply a quiet NaN when a signaling
>> NaN
>>> is requested, 
>>> 
>>> x = IEEE_VALUE(x,IEEE_SIGNALING_NAN)
>>> 
>>> might not assign a signaling NaN to X.  How does one reliably fill a
>>> real variable (scalar or otherwise) with signaling NaN?
>> 
>> 
>> This seems like a reasonable question, since programs often use sNaN
>> to fill in “undefined” variables, to catch later, improper use. 
> 
> Malcolm remembered that we had a discussion about this a long time ago.
> I also believed we had had a discussion, but couldn't find any papers
> about it.  IIRC, the reason Bill gave is precisely the reason for the
> earlier discussion.
> 
> I have a recollection that I proposed a "SET_IEEE_VALUE" subroutine, but
> I couldn't find a paper about it, so maybe it was only an e-mail
> proposal.  We could have described it without the weasel words in the
> IEEE_VALUE function.  Being a subroutine, and not having the weasel
> words, vendors might not have been tempted to use the x87 stack just to
> store a bit pattern into a variable.
> 

I think there is a more fundamental issue here.  In the interpretation of intrinsic assignment we say  

"Execution of an intrinsic assignment causes, …  the definition of the variable with the resulting value.”

If the kind and type of the expression and variable are the same, there should be no conversion of the value.  Having an assignment magically change the value of the expression before defining the variable violates a pretty fundamental assumption of Fortran.  Certainly it violates the “least surprise” principle.   There are reasons why compilers do not generate x87 instructions. 

Cheers,
Bill


Bill Long                                                                       longb at cray.com
Principal Engineer, Fortran Technical Support &   voice:  651-605-9024
Bioinformatics Software Development                      fax:  651-605-9143
Cray Inc./ 2131 Lindau Lane/  Suite 1000/  Bloomington, MN  55425




More information about the J3 mailing list