This is the mail archive of the gcc-patches@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]

Re: [Patch, Fortran] PR34333 - Handle parameter NAN properly in MAX, MIN, == etc.


Tobias Burnus wrote:
:ADDPATCH fortran:

The program (to be compiled with -fno-range-check)

real, parameter :: nan = 0.0/0.0
if (nan == nan) call abort()
print *, max(nan, 4.0) ! shall print "4.0"

should not abort as  (nan /= nan) shall evaluate as true. This patch
ensures that comparisons and MIN/MAX work properly for NaN, by using
mpfr_min and mpfr_max instead of home-grown mpfr_cmp/mpfr_set solutions.

It additionally replaces mpfr_cmp by mpfr_equal_p etc. which take NaN
into account. I had to pass the wanted argument to gfc_compare_expr to
ensure that for  "nan > nan", "nan < nan" and "nan == nan" the result is
always false.

Build and regression tested on x86-64-linux.
OK for the trunk?

Tobias

PS: I essentially copied the test case nan_1.f90 and changed the
variables to parameters.

OK,

Thanks,

Jerry


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