public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/48979] New: FRACTION und EXPONENT return invalid results for infinity/NaN
@ 2011-05-12 15:27 thenlich at users dot sourceforge.net
  2011-05-12 16:34 ` [Bug fortran/48979] " kargl at gcc dot gnu.org
                   ` (18 more replies)
  0 siblings, 19 replies; 20+ messages in thread
From: thenlich at users dot sourceforge.net @ 2011-05-12 15:27 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48979

           Summary: FRACTION und EXPONENT return invalid results for
                    infinity/NaN
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: thenlich@users.sourceforge.net


program test_fractnan
    real, parameter :: pinfp = transfer(z'7F800000', 0.0)
    real, parameter :: ninfp = transfer(z'FF800000', 0.0)
    real, parameter :: nanp = transfer(z'7FD00000', 0.0)
    real, parameter :: zerop = 0.0
    real :: nan = nanp, pinf = pinfp, ninf = ninfp, zero = zerop

    print 100, zero,  zero,  fraction(zero),  fraction(zero),  exponent(zero)
    print 100, zerop, zerop, fraction(zerop), fraction(zerop), exponent(zerop)
    print 100, nan,   nan,   fraction(nan),   fraction(nan),   exponent(nan)
    print 100, nanp,  nanp,  fraction(nanp),  fraction(nanp),  exponent(nanp)
    print 100, ninf,  ninf,  fraction(ninf),  fraction(ninf),  exponent(ninf)
    print 100, ninfp, ninfp, fraction(ninfp), fraction(ninfp), exponent(ninfp)
    print 100, pinf,  pinf,  fraction(pinf),  fraction(pinf),  exponent(pinf)
    print 100, pinfp, pinfp, fraction(pinfp), fraction(pinfp), exponent(pinfp)
100 format (f10.5,1x,z8,1x,f10.5,1x,z8,1x,i11)
end program test_fractnan

Result:
   0.00000        0    0.00000        0           0
   0.00000        0    0.00000        0           0
       NaN 7FD00000        NaN 7FD00000           0
       NaN 7FD00000    0.00000        0           0
 -Infinity FF800000  -Infinity FF800000           0
 -Infinity FF800000        NaN 7FC00000 -2147483645
  Infinity 7F800000   Infinity 7F800000           0
  Infinity 7F800000        NaN 7FC00000 -2147483645

Expected result (-std=f2003):
   0.00000        0    0.00000        0           0
   0.00000        0    0.00000        0           0
       NaN 7FD00000        NaN 7FD00000  2147483647
       NaN 7FD00000        NaN 7FD00000  2147483647
 -Infinity FF800000  -Infinity FF800000  2147483647
 -Infinity FF800000  -Infinity FF800000  2147483647
  Infinity 7F800000   Infinity 7F800000  2147483647
  Infinity 7F800000   Infinity 7F800000  2147483647

Expected result (-std=f2008):
   0.00000        0    0.00000        0           0
   0.00000        0    0.00000        0           0
       NaN 7FD00000        NaN 7FD00000  2147483647
       NaN 7FD00000        NaN 7FD00000  2147483647
 -Infinity FF800000        NaN 7FC00000  2147483647
 -Infinity FF800000        NaN 7FC00000  2147483647
  Infinity 7F800000        NaN 7FC00000  2147483647
  Infinity 7F800000        NaN 7FC00000  2147483647

EXPONENT(X)
Fortran 2003/2008:
If X is an IEEE infinity or NaN, the result has the value HUGE (0).

FRACTION(X)
Fortran 2003:
If X is an IEEE infinity, the result is that infinity. If X is an IEEE NaN, the
result is that NaN.

Fortran 2008:
If X is an IEEE NaN, the result is that NaN. If X is an IEEE infinity, the
result is an IEEE NaN.

Bug 1:
The program does not compile without -fno-range-check.

Bug 2:
Different results are returned for a variables with values of NaN/Infinity and
compile-time constants NaN/Infinity.

Bug 3:
EXPONENT should be HUGE(0)=2147483647 for NaN/Infinity.


^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2014-10-19 20:50 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-12 15:27 [Bug fortran/48979] New: FRACTION und EXPONENT return invalid results for infinity/NaN thenlich at users dot sourceforge.net
2011-05-12 16:34 ` [Bug fortran/48979] " kargl at gcc dot gnu.org
2011-05-12 18:00 ` thenlich at users dot sourceforge.net
2011-05-12 18:04 ` burnus at gcc dot gnu.org
2011-05-12 18:37 ` sgk at troutmask dot apl.washington.edu
2011-05-12 19:33 ` sgk at troutmask dot apl.washington.edu
2011-05-12 19:45 ` sgk at troutmask dot apl.washington.edu
2011-05-12 20:32 ` sgk at troutmask dot apl.washington.edu
2011-05-12 21:07 ` burnus at gcc dot gnu.org
2011-05-12 21:11 ` sgk at troutmask dot apl.washington.edu
2011-05-12 21:12 ` sgk at troutmask dot apl.washington.edu
2011-05-13  9:28 ` thenlich at users dot sourceforge.net
2011-05-13 10:04 ` burnus at gcc dot gnu.org
2011-05-13 15:07 ` sgk at troutmask dot apl.washington.edu
2011-05-22 23:19 ` kargl at gcc dot gnu.org
2011-05-22 23:38 ` kargl at gcc dot gnu.org
2014-01-07  8:26 ` dominiq at lps dot ens.fr
2014-09-27  8:45 ` fxcoudert at gcc dot gnu.org
2014-10-11 16:58 ` fxcoudert at gcc dot gnu.org
2014-10-19 21:04 ` fxcoudert at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).