From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7305 invoked by alias); 3 Jul 2009 18:15:56 -0000 Received: (qmail 7225 invoked by uid 48); 3 Jul 2009 18:15:42 -0000 Date: Fri, 03 Jul 2009 18:15:00 -0000 Subject: [Bug fortran/40643] New: maxloc/minloc: Wrong result for NaN at position 1 X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "burnus at gcc dot gnu dot org" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2009-07/txt/msg00279.txt.bz2 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