This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/40643] New: maxloc/minloc: Wrong result for NaN at position 1


Per IEEE 754:2008, one has max(x,NaN) == max(NaN,x) == x. Gfortran's inline
version of maxloc, maxval and max (ditto for min*) follows this. However, the
libgfortran version does not:

real :: r(4), z
z = 0.0
r = (/ z/z, -1., -42., 849. /)
print *,r
print *, minloc(r), minval(r)
print *, maxloc(r), maxval(r)
end

Produces:

             NaN  -1.0000000      -42.000000       849.00000
           1  -42.000000
           1   849.00000

Correct is - as ifort has -:

 NaN             -1.000000      -42.00000       849.0000
           3  -42.00000
           4   849.0000


-- 
           Summary: maxloc/minloc: Wrong result for NaN at position 1
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: burnus at gcc dot gnu dot org


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]