[Bug libfortran/50105] [4.6/4.7 Regression] I/O with g6.5 - wrong number of "**" shown
burnus at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Aug 19 11:17:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50105
--- Comment #8 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-08-19 10:34:13 UTC ---
A simple (partial) revert of the patch of PR 47285
(http://gcc.gnu.org/ml/fortran/2011-01/msg00226.html) will lead to wrong
results as one does not honour the following.
write(*,'(G5.5E5)') -10000.
will then print "* " instead of the correct "*****" which is printed
currently. However, due to "w-(e+2) = 5-(5+2) > 0" [where the symbols are:
Gw.dEe], the whole field should be filled with asterisks, cf. below.
I think best is to do a full revert, replace the following hack in the patch
+ if (e > 4)\
+ e = 4;\
by a simply check for w-4 > 0 or w-(e+2) > 0 and - if failing - fill it with
"*" and return. Only when succeeding, move to the FMT_F. In the latter padding
section, one can then always pad with ' '. I have not yet checked whether the
+ nb = nb >= w ? 0 : nb;\
is then still required or not.
>From the F2008 standard:
"if an exponent exceeds its specified or implied width using the ... G edit
descriptor," [the field should be filled with "*"].
One has for "Gw.d" n = 4 and for "Gw.d.Ee" it is "n = e+2". The requirement is
"w-n > 0". In that case, one needs to fill the whole width w (of "Gw.d") with
asterisks.
If "w-n > 0", one has "F(w-n).(dd),n(' ')" with some "dd" depending on rounding
and magnitude of the value. In that case, only (w-n) is - if needed - filled
with asterisks.
(For the calculations, see 10.7.5.2.2 (below the first table); see also
10.7.2.1 in comment 1 with the interpretation in comment 7.)
More information about the Gcc-bugs
mailing list