https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117805

--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to kargls from comment #7)
> (In reply to Richard Biener from comment #3)
> > You can get the desired behavior with -fno-signed-zeros I think - it might
> > be reasonable to add an additional -fcx-* flag specifying that just for
> > _Complex
> > operations signed zeros can be ignored (IIRC non-complex REAL have specified
> > behavior wrt signed zeros, so a -fno-signed-zeros default for Fortran would
> > be wrong).
> > 
> > So, -fcx-no-signed-zeros or maybe simply alter -fcx-fortran-rules to cover
> > signed zeros?
> 
> It my opinion that -fcx-fortran-rules should be removed.  It's exist
> does match anything specified in the Fortran standard.  But that's
> for another PR.

I think -fcx-fortran-rules was added for usage by C/C++ code and people
wanting the behavior (and speed) they were used to from Fortran code.
On the C/C++ side we only had strict conformance and -ffast-math while
the gfortran (or was it g77?) default offered some in-between.

> It is more than just adding a new option.
> 
>    program testprogram
> 
>    implicit none
> 
>    real, parameter :: rc = sign(0., -1.)
>    complex, parameter :: zc = nzero * (0, 1)
>    real r 
>    complex z
> 
>    print *, rc, zc
> 
>    r = sign(0., -1.)
>    z = r * (0, 1)
>    print *, r, z
> 
>   end program 
> 
> % gfcx -o z -O a.f90 && ./z
>   -0.00000000                (-0.00000000,0.00000000)
>   -0.00000000                (-0.00000000,0.00000000)
> % gfcx -o z -Ofast a.f90 && ./z
>   -0.00000000                (-0.00000000,0.00000000)
>   -0.00000000               (-0.00000000,-0.00000000)

I think gfortrans position on how IEEE rules affect _Complex should be
documented in the manual - the C manual has a section on Implementation
Defined Behavior (but the C standard mandates this for items defered to
implementations).

Internally GCC uses flag_complex_method to indicate how _Complex
multiplication and esp. division are implemented.  On the user-facing
side there's -fcx-limited-range and -fcx-fortran-rules controlling
this flag.  -ffast-math sets -fcx-limited-range.

Reply via email to