This is the mail archive of the
mailing list for the GCC project.
Re: [Patch, Fortran] PR34333 - Handle parameter NAN properly in MAX, MIN, == etc.
- From: Jerry DeLisle <jvdelisle at verizon dot net>
- To: Tobias Burnus <burnus at net-b dot de>
- Cc: "'fortran at gcc dot gnu dot org'" <fortran at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 04 Dec 2007 18:37:55 -0800
- Subject: Re: [Patch, Fortran] PR34333 - Handle parameter NAN properly in MAX, MIN, == etc.
- References: <4755BC0D.email@example.com>
Tobias Burnus wrote:
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
Build and regression tested on x86-64-linux.
OK for the trunk?
PS: I essentially copied the test case nan_1.f90 and changed the
variables to parameters.