llvm-project
llvm-project copied to clipboard
[Flang] FRACTION of +/- Inf, REAL and DOUBLE PRECISION, returns NaN instead of +/- Inf
The intrinsic FRACTION should return Inf, not NaN, for Inf argument.
The Intel compiler returns Inf, GNU returns NaN.
Program test_fraction_inf
Real :: x
Real(Kind(1.d0)) :: y
x = Huge(x) ; y = Huge(y)
Call s(x,y)
Contains
Subroutine s(x,y)
Real :: x
Real(Kind(1.d0)) :: y
x = x + x; y = y + y
Print *, x,y ! expected Inf
Print *, Fraction(x), Fraction(y) ! expected Inf
x = -x ; y = -y
Print *, Fraction(x), Fraction(y) ! expected Inf
End Subroutine s
End Program Test_fraction_inf
It might be prudent to check the Fortran standard. 16.9.90 FRACTION (X) ... If X is an IEEE infinity, the result is an IEEE NaN.
Working as intended; closing bug.