This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/15441] RRSPACING broken for denormals
- From: "kargl at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 4 Oct 2006 17:20:59 -0000
- Subject: [Bug fortran/15441] RRSPACING broken for denormals
- References: <bug-15441-8513@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #8 from kargl at gcc dot gnu dot org 2006-10-04 17:20 -------
gfortran still gets rrspacing of subnormal wrong.
troutmask:sgk[215] ./z
s = 4.4081038E-39 <-- Subnormal named constant
x = 4.4081038E-39 <-- Subnormal variable
rrspacing(s) = 1.2582912E+07 <-- Constant folding
my_rrspacing(x) = 1.2582912E+07 <-- Fortran code
rrspacing(x) = NaN <-- gfortran inline
program h
real, parameter :: s = 0.375 * tiny(1.)
real x
x = s
print *, 's =', s, ' <-- Subnormal named constant'
print *, 'x =', x, ' <-- Subnormal variable'
print *, 'rrspacing(s) =', rrspacing(s), ' <-- Constant folding'
print *, 'my_rrspacing(x) =', my_rrspacing(x), ' <-- Fortran code'
print *, 'rrspacing(x) =', rrspacing(x), ' <-- gfortran inline'
contains
function my_rrspacing(x)
implicit none
real my_rrspacing
real, intent(in) :: x
real y
y = abs(x)
if (y == 0.) then
my_rrspacing = 0.
else
my_rrspacing = scale(scale(y, - exponent(y)), digits(y))
end if
end function my_rrspacing
end program h
The F95 standard says that rrspacing(x) = | x * b**(-e) | 2**p where b, e,
and p are the radix, exponent of x, and prcision.
trans-intrinsics.c (gfc_conv_intrinsic_rrspacing) appears to mutilate the
mathematical expression.
--
kargl at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
Resolution|INVALID |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15441