public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "sgk at troutmask dot apl dot washington dot edu" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libfortran/19155] blanks not treated as zeros in 'E' format read
Date: Sun, 26 Dec 2004 19:45:00 -0000	[thread overview]
Message-ID: <20041226194505.7693.qmail@sourceware.org> (raw)
In-Reply-To: <20041225214626.19155.Thomas.Koenig@online.de>


------- Additional Comments From sgk at troutmask dot apl dot washington dot edu  2004-12-26 19:45 -------
Looks like you've found a bug in g77, and if you're reduction of NIST's 110
test is correct, then NIST also has the same bug.   Here follows my digging
into this problem.

>From the Fortran 77 standard (ansi-x3dot9-1978-Fortran77.pdf) 

  4.4.1 Basic Real Constant
  The form of a basic real constant is an optional sign, an integer part,
  a decimal point, and a fractional part, in that order.  Both the integer
  part and the fractional part are strings of digits; either of these parts
  may be omitted but not both.  A basic real constant may be written with
  more digits than a processor will use to approximate the value of the
  constant.  A basic real constant is interpreted as a decimal number.

  13.5.9 Numeric Editing
  The I, F, E, D, and G edit descriptors are used to specify input/output
  of integer, real, double precision, and complex data.  The following
  general rules apply:
    (1) On input, leading blanks are not significant.  The interpretation
        of blanks, other than leading blanks, is determined by a combination
        of any BLANK= specifier and any BN or BZ blank control that is
        currently in effect for the unit (13.5.8).  Plus signs may be omitted.
        A field of all blanks is considered to be zero.

It appears that the last sentence has been misinterpreted by g77 and NIST.
The wording from a May 2004 draft (04-007.pdf) of the newest standard is

   R416 signed-real-literal-constant
           is [ sign ] real-literal-constant
   R417 real-literal-constant
           is significand [ exponent-letter exponent ] [ kind-param ]
           or digit-string exponent-letter exponent [ kind-param ]
  R418 significand
           is digit-string . [ digit-string ]
           or . digit-string
  R419 exponent-letter
           is E
           or D
  R420 exponent
           is signed-digit-string

  10.6.1      Numeric editing
  The I, B, O, Z, F, E, EN, ES, D, and G edit descriptors may be used to
  specify the input/output of integer, real, and complex data.  The
  following general rules apply:
    (1) On input, leading blanks are not significant.  When the input field
        is not an IEEE exceptional specification (10.6.1.2.1), the
        interpretation of blanks, other than leading blanks, is determined
        by the blank interpretation mode (10.7.6).  Plus signs may be omitted.
        A field containing only blanks is considered to be zero.

The first excerpt is the BNF of a real number.  The second excerpt contains
the same misinterpreted sentence.

So, your output of 'E+00' in not a valid real number under either F77 or F2003
(and most likely F95).  Secondly, the field you are reading is with the 
E15.8 format, which is 15 characters wide, and this field does not contain only
blanks because you wrote E+00 into it.

If you change "write(19,'(A15)') 'E+00'" to the obvious blank-filled field,
gfortran does the right thing: "write(19,'(A15)') '               '"

-- 
steve

-- 


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


  reply	other threads:[~2004-12-26 19:45 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-12-25 21:46 [Bug libfortran/19155] New: " Thomas dot Koenig at online dot de
2004-12-26 19:45 ` sgk at troutmask dot apl dot washington dot edu [this message]
2005-01-06 14:43 ` [Bug libfortran/19155] " tobi at gcc dot gnu dot org
2005-01-16 23:45 ` [Bug libfortran/19155] blanks not treated as zeros in 'E' format read (NIST FM110.FOR) bdavis at gcc dot gnu dot org
2005-03-02 10:31 ` coudert at clipper dot ens dot fr
2005-03-11 21:21 ` Thomas dot Koenig at online dot de
2005-03-11 22:34 ` sgk at troutmask dot apl dot washington dot edu
2005-03-31 16:38 ` fxcoudert at gcc dot gnu dot org
2005-03-31 21:43 ` kargl at gcc dot gnu dot org
2005-04-05  9:41 ` fxcoudert at gcc dot gnu dot org
2005-05-09 11:31 ` cvs-commit at gcc dot gnu dot org
2005-05-09 11:35 ` cvs-commit at gcc dot gnu dot org
2005-05-09 11:40 ` fxcoudert at gcc dot gnu dot org
2005-05-09 21:38 ` pinskia at gcc dot gnu dot org
2005-05-16 19:45 ` dje at gcc dot gnu dot org
2005-05-16 20:19 ` fxcoudert at gcc dot gnu dot org
2005-06-02  5:45 ` fxcoudert at gcc dot gnu dot org
2005-06-12  8:05 ` fxcoudert at gcc dot gnu dot org
2005-06-12  9:21 ` fxcoudert at gcc dot gnu dot org
2005-06-12 17:48 ` kargl at gcc dot gnu dot org
2005-06-12 19:59 ` cvs-commit at gcc dot gnu dot org
2005-06-12 20:05 ` [Bug libfortran/19155] [4.0 only] " fxcoudert at gcc dot gnu dot org
2005-06-16 22:39 ` cvs-commit at gcc dot gnu dot org
2005-06-16 23:04 ` fxcoudert at gcc dot gnu dot org
2005-06-17 15:16 ` dje at gcc dot gnu dot org
2005-06-17 15:40 ` fxcoudert at gcc dot gnu dot org
2005-06-17 16:21 ` cvs-commit at gcc dot gnu dot org
2005-06-17 16:24 ` cvs-commit at gcc dot gnu dot org
2005-06-17 16:25 ` fxcoudert at gcc dot gnu dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20041226194505.7693.qmail@sourceware.org \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).