http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49188

           Summary: Mismatch between -fsign-zero documentation and
                    formatted output
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libfortran
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: thenl...@users.sourceforge.net


The documentation of the -fsign-zero option mentions "floating point numbers of
value zero with the sign bit set":

"When enabled, floating point numbers of value zero with the sign bit set are
written as negative number in formatted output and treated as negative in the
SIGN intrinsic. fno-sign-zero does not print the negative sign of zero values
and regards zero as positive number in the SIGN intrinsic for compatibility
with F77. Default behavior is to show the negative sign."

However the flag also affects the output of numbers with a value other than
zero, which have their non-zero digits truncated due to formatting.

E.g.:
    print "(rc,f4.1)", -0.04
-fsign-zero:
-0.0
-fno-sign-zero:
 0.0

This fno-sign-zero behaviour is not according to the Fortran standard ("a minus
sign if the internal value is negative") including F77 which is explicitly
mentioned in the documentation. (Or is this referring to a specific, possibly
non-Fortran77-compliant compiler named F77?)

The only sense this would make is if this option would be restricted to
actually do what it says in the documentation, regarding a zero with the sign
bit set as a mathematical zero, a non-negative value.

In my opinion the formatting routines for real numbers should be changed to
only affect zero values.

Additionally, the last sentence ("Default behavior is to show the negative
sign.") should be made more precise (e.g. "The option is enabled by default")
to reflect that the SIGN intrinsic is also affected by the default setting.

Reply via email to