From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7720 invoked by alias); 26 Dec 2004 19:45:08 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 7694 invoked by uid 48); 26 Dec 2004 19:45:05 -0000 Date: Sun, 26 Dec 2004 19:45:00 -0000 Message-ID: <20041226194505.7693.qmail@sourceware.org> From: "sgk at troutmask dot apl dot washington dot edu" To: gcc-bugs@gcc.gnu.org In-Reply-To: <20041225214626.19155.Thomas.Koenig@online.de> References: <20041225214626.19155.Thomas.Koenig@online.de> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug libfortran/19155] blanks not treated as zeros in 'E' format read X-Bugzilla-Reason: CC X-SW-Source: 2004-12/txt/msg03563.txt.bz2 List-Id: ------- 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