Hi, When I check a PR93709, I find the testcase maxlocval_4.f90 and minlocval_4.f90 are checking `maxval/minval` on `-inf` and `nan`. https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;a=blob_plain;f=gcc/testsuite/gfortran.dg/maxlocval_4.f90;hb=HEAD There are code like: ``` l5 = .true. l5(1,1) = .false. l5(1,2) = .false. l5(2,3) = .false. a = reshape ((/ nan, nan, nan, minf, minf, minf, minf, pinf, minf /), (/ 3, 3 /)) b = maxval (a, dim = 1) if (.not.isnan(b(1))) STOP 3 a = nan a(1,3) = minf if (maxval (a).ne.minf) STOP 65 if (maxval (a, mask = l5).ne.minf) STOP 70 ```
While we know, as gfortran manual said at 5.4 MAX and MIN intrinsics with REAL NaN arguments: https://gcc.gnu.org/onlinedocs/gcc-9.2.0/gfortran/MAX-and-MIN-intrinsics-with-REAL-NaN-arguments.html#MAX-and-MIN-intrinsics-with-REAL-NaN-arguments ``` The Fortran standard does not specify what the result of the MAX and MIN intrinsics are if one of the arguments is a NaN. Accordingly, the GNU Fortran compiler does not specify that either, as this allows for faster and more compact code to be generated. If the programmer wishes to take some specific action in case one of the arguments is a NaN, it is necessary to explicitly test the arguments before calling MAX or MIN, e.g. with the IEEE_IS_NAN function from the intrinsic module IEEE_ARITHMETIC. ``` The test case does not check NaN explicitly. So, strictly speaking, this code may need more stronger to check NaN, otherwise it may STOP during execution, and this STOP is acceptable. Right? With -ffast-math -O3, this case `STOP 3` on a few platforms, e.g. ppc64le/x86. Thanks, Jiufu