PR32083 - Use correct sign for -Inf in real.c's mpfr_from_real

Brooks Moses brooks.moses@codesourcery.com
Sat May 26 23:40:00 GMT 2007


Tobias Burnus wrote:
> This should be obvious. REAL_VALUE_TYPE's sign is one for negative
> numbers and zero for positive numbers.
> mpfr_set_inf is positive for sign >= 0, and negative for sign < 0.
[...]
> 2007-05-26  Tobias Burnus  <burnus@net-b.de>
> 
> 	PR fortran/32083
> 	* gfortran.dg/transfer_simplify_3.f90: New.
> 
> Index: real.c
> ===================================================================
> --- real.c	(revision 125096)
> +++ real.c	(working copy)
> @@ -4746,7 +4746,7 @@ mpfr_from_real (mpfr_ptr m, const REAL_V
>    /* Take care of Infinity and NaN.  */
>    if (r->cl == rvc_inf)
>      {
> -      mpfr_set_inf (m, r->sign);
> +      mpfr_set_inf (m, r->sign == 1 ? -1 : 1);
>        return;
>      }

Argh!  Obviously that's my fault -- thanks for tracking it down.

It looks like all of the other uses of "sign" in real.c leave off the 
"== 1", and just have "r->sign ? -1 : 1", so this should probably be 
changed to that form.

I'm obviously not a middle-end maintainer, but I _did_ write the code in 
question, and this correction seems obvious to me, so I think it's okay 
to commit on that basis.

(Also, for the record, this particular piece of code is not used by 
anything other than the Fortran front end, so there won't be a C or C++ 
testcase to exercise the correction.)

- Brooks



More information about the Fortran mailing list