This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/35036] illegal E format descriptor produces wrong output
- From: "jvdelisle at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 2 Feb 2008 08:28:07 -0000
- Subject: [Bug fortran/35036] illegal E format descriptor produces wrong output
- References: <bug-35036-15709@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #11 from jvdelisle at gcc dot gnu dot org 2008-02-02 08:28 -------
Here is a different view on this; from the standard:
For an internal value that is neither an IEEE infinity nor a NaN, the form of
the output field for a scale factor of zero is:
[ ± ] [0].x1 x2 . . . xd exp
where:
± signifies a plus sign or a minus sign.
. signifies a decimal symbol (10.5).
x1 x2 . . . xd are the d most significant digits of the internal value
after rounding.
You will notice that the series of significant digits begins with x(1) going up
to x(d). x(0) is not defined in the allowable output. This makes sense since
this particular format has no significant digits to the left of the decimal
point and it is meaningless not to display at least 1 significant digit.
I would say then that the code is invalid.
Further, I don't think the discussion in the standard about the scaling factor
k is intended to say anything about the value of d, it is only speaking of what
to do under certain conditions of k relative to d.
Now if you look at the output from this simple test program:
a = 1.e5
write(*,'(E15.0)') a
write(*,'(E15.1)') a
write(*,'(E15.2)') a
write(*,'(E15.3)') a
write(*,'(E15.4)') a
write(*,'(E15.5)') a
write(*,'(E15.6)') a
write(*,'(E15.7)') a
write(*,'(E15.8)') a
end
$ gfc pr35036.f
$ ./a.out
0.E+01
0.1E+06
0.10E+06
0.100E+06
0.1000E+06
0.10000E+06
0.100000E+06
0.1000000E+06
0.10000000E+06
The pattern is clear and it breaks to nonsense for d=0.
The standard (F2003) also says: "10.6.1 (5) However, the processor shall not
produce asterisks if the field width is not exceeded when optional characters
are omitted.
I don't think this case is an issue of exceeding the width. Therefore I think
a runtime error is appropriate. Even better would be a compile time error as
well.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35036