public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libfortran/49188] New: Mismatch between -fsign-zero documentation and formatted output
@ 2011-05-27 10:54 thenlich at users dot sourceforge.net
  2011-05-27 12:36 ` [Bug libfortran/49188] " burnus at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: thenlich at users dot sourceforge.net @ 2011-05-27 10:54 UTC (permalink / raw)
  To: gcc-bugs

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: unassigned@gcc.gnu.org
        ReportedBy: thenlich@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.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libfortran/49188] Mismatch between -fsign-zero documentation and formatted output
  2011-05-27 10:54 [Bug libfortran/49188] New: Mismatch between -fsign-zero documentation and formatted output thenlich at users dot sourceforge.net
@ 2011-05-27 12:36 ` burnus at gcc dot gnu.org
  2011-05-27 18:46 ` thenlich at users dot sourceforge.net
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-05-27 12:36 UTC (permalink / raw)
  To: gcc-bugs

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

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |burnus at gcc dot gnu.org

--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-05-27 12:31:21 UTC ---
(In reply to comment #0)
> This fno-sign-zero behaviour is not according to the Fortran standard

Well, -fno-sign-zero is definitely not according to the Fortran 90+ standard as
one there has signed zero. Fortran 77 does not really say anything about signed
zeros, thus, some programs assume that there is only one zero, which is
positive. However, I think according to the Fortran 77 standard, a negative
zero is also a valid implementation choice.

> ("a minus sign if the internal value is negative") including F77 which is
> explicitly mentioned in the documentation.

For cross-reference the quote is from "13.5.9.2.1  F_Editing" at
  ftp://ftp.nag.co.uk/sc22wg5/ARCHIVE/Fortran77.html


I think the current behavior is OK. For programs, which do not handle negative
zeros, one should never print a minus - independent whether the internal value
is exactly zero or only after truncation. If I run your program (w/o "rc,")
with g77, I get:
 0.0
Ditto with ifort (w/ and w/o "rc,", unless "-assume minus0"), pathf95 and
pgf90.

There are really programs - Fortran programs or post-processing programs, which
rely on not printing "-0.0" and on the non-conforming SIGN behavior (with
regards to negative zeros). Thus, it does not really matter whether
-fno-sign-zero breaks the Fortran standard or not, if programs rely on it and
if gfortran conforms to the standard by default.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libfortran/49188] Mismatch between -fsign-zero documentation and formatted output
  2011-05-27 10:54 [Bug libfortran/49188] New: Mismatch between -fsign-zero documentation and formatted output thenlich at users dot sourceforge.net
  2011-05-27 12:36 ` [Bug libfortran/49188] " burnus at gcc dot gnu.org
@ 2011-05-27 18:46 ` thenlich at users dot sourceforge.net
  2011-11-07 22:26 ` fxcoudert at gcc dot gnu.org
  2011-11-07 22:33 ` fxcoudert at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: thenlich at users dot sourceforge.net @ 2011-05-27 18:46 UTC (permalink / raw)
  To: gcc-bugs

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

Thomas Henlich <thenlich at users dot sourceforge.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |minor

--- Comment #2 from Thomas Henlich <thenlich at users dot sourceforge.net> 2011-05-27 18:41:38 UTC ---
In this case a more precise documentation should be something like:

"When enabled, floating point numbers with the sign bit set are always written
with a negative sign even if the formatted output contains no other digits than
zero. In addition, floating point numbers of value zero with the sign bit set
are treated as negative in the SIGN intrinsic. fno-sign-zero does not print the
negative sign of such values and regards zero as positive number in the SIGN
intrinsic for compatibility with g77. fsign-zero is the default."


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libfortran/49188] Mismatch between -fsign-zero documentation and formatted output
  2011-05-27 10:54 [Bug libfortran/49188] New: Mismatch between -fsign-zero documentation and formatted output thenlich at users dot sourceforge.net
  2011-05-27 12:36 ` [Bug libfortran/49188] " burnus at gcc dot gnu.org
  2011-05-27 18:46 ` thenlich at users dot sourceforge.net
@ 2011-11-07 22:26 ` fxcoudert at gcc dot gnu.org
  2011-11-07 22:33 ` fxcoudert at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: fxcoudert at gcc dot gnu.org @ 2011-11-07 22:26 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> 2011-11-07 22:22:02 UTC ---
Author: fxcoudert
Date: Mon Nov  7 22:21:54 2011
New Revision: 181127

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=181127
Log:
    PR libfortran/49188
    PR libfortran/49336
    * invoke.texi: Fix documentation of fsign-zero option. Remove
    contractions.
    * intrinsic.texi: Fix ATAN2 documentation for signed zeros.
    Remove contractions.
    * gfortran.texi: Remove contractions.

Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/gfortran.texi
    trunk/gcc/fortran/intrinsic.texi
    trunk/gcc/fortran/invoke.texi


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libfortran/49188] Mismatch between -fsign-zero documentation and formatted output
  2011-05-27 10:54 [Bug libfortran/49188] New: Mismatch between -fsign-zero documentation and formatted output thenlich at users dot sourceforge.net
                   ` (2 preceding siblings ...)
  2011-11-07 22:26 ` fxcoudert at gcc dot gnu.org
@ 2011-11-07 22:33 ` fxcoudert at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: fxcoudert at gcc dot gnu.org @ 2011-11-07 22:33 UTC (permalink / raw)
  To: gcc-bugs

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

Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
                 CC|                            |fxcoudert at gcc dot
                   |                            |gnu.org
         Resolution|                            |FIXED
   Target Milestone|---                         |4.7.0

--- Comment #4 from Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> 2011-11-07 22:24:38 UTC ---
Fixed on trunk.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-11-07 22:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-27 10:54 [Bug libfortran/49188] New: Mismatch between -fsign-zero documentation and formatted output thenlich at users dot sourceforge.net
2011-05-27 12:36 ` [Bug libfortran/49188] " burnus at gcc dot gnu.org
2011-05-27 18:46 ` thenlich at users dot sourceforge.net
2011-11-07 22:26 ` fxcoudert at gcc dot gnu.org
2011-11-07 22:33 ` fxcoudert at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).