https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82207
Bug ID: 82207
Summary: ieee_class identifies signaling NaNs as quiet NaNs
Product: gcc
Version: 7.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: sacks at ucar dot edu
Target Milestone: ---
With gfortran 5.4.0, gfortran 6.3.0 and gfortran 7.1.0, running ieee_class on a
signaling NaN identifies it as an ieee_quiet_nan rather than an
ieee_signaling_nan.
(Sorry, I don't have a more recent gfortran version readily available.)
I have tried creating the NaN values using both:
(1)
my_nan = ieee_value(my_nan, ieee_signaling_nan)
(2)
integer, parameter :: i8 = selected_int_kind(13)
integer(i8), parameter :: dsnan_pat = int(Z'7FF4000000000000',i8)
my_nan = transfer(dsnan_pat, my_nan)
In both cases, I then used this code to print the type of NaN:
my_class = ieee_class(my_nan)
if (my_class == ieee_signaling_nan) then
print *, 'signaling nan'
else if (my_class == ieee_quiet_nan) then
print *, 'quiet nan'
else if (my_class == ieee_other_value) then
print *, 'other value'
else
print *, 'UNKNOWN'
end if
and it printed 'quiet nan'.
For full code and additional information, see:
https://github.com/NCAR/billsacks-gfortran-snan/tree/master_n01
(Note that that code and README file includes some additional stuff not
directly relevant to this bug, since I was using that test program to test a
number of aspects of gfortran's NaN handling.)