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] PR40675: Fix SIGN for negative zero


On Wed, Jul 08, 2009 at 07:02:29PM +0200, Tobias Burnus wrote:
> Dear all,
> 
> the attached patch does two things:
> 
> a) It properly treats -0.0 in initialization expressions;
>    before 0.0 and -0.0 where treated alike and the code was
>    quite complicated. (The new code requires MPFR 2.3.0 but
>    that is also what GCC requires.)
>    As "-0.0" does not exist, only "-" applied on "0.0"
>    (yielding 0.0) and as I failed to come up with a working
>    example for a -0.0 (even using nearest and trigonometric
>    functions), I think I can negate the practical relevance.
> 
> b) For run-time evaluation: One can create programs which
>    depend on SIGN(x, 0.0) and sign(x, -0.0) returning the
>    same value. Whether such programs are valid Fortran 77/90
>    programs is arguable but they are not outright wrong and
>    compilers such as g77, ifort (up to 11.1), sunf95, ...
>    treat 0.0 and -0.0 as positive in SIGN.
>    As we already had -fsign-zero to print "-0.0" as "0.0" for
>    Fortran 77 compatibility, I extended this to SIGN, which
>    allows a F77 program at Sandia National Lab to run.
> 
> Warning: -fsign-zero (gfortran) and -fsigned-zeros (middle end)
> shall not be confused!
> 
> Build and regtested on x86-64-linux.
> OK for the trunk?
> 

See the audit trail in the PR.  I'd prefer the two testcases
I added to the PR instead of the one you included here.  First,
your testcase should at least change "write(*,*) 'fail'" to
"call abort()" and it should remove the "write(*,*) 'pass'".
Second, your test case doesn't test your change to simplify.c.
As a final comment, gfortran should probably include -fsign-zero
under the -std=legacy option.

Index: options.c
===================================================================
--- options.c   (revision 149287)
+++ options.c   (working copy)
@@ -854,6 +854,7 @@ gfc_handle_option (size_t scode, const c
 
     case OPT_std_legacy:
       set_default_std_flags ();
+      gfc_option.flag_sign_zero = 0;
       gfc_option.warn_std = 0;
       break;

OK after consideration for my comments.

-- 
Steve


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