Bug 17871 - libgfortran, g77: regression, zero has non-zero exponent
Summary: libgfortran, g77: regression, zero has non-zero exponent
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libfortran (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: 4.0.0
Assignee: Francois-Xavier Coudert
URL:
Keywords:
Depends on:
Blocks: 19292
  Show dependency treegraph
 
Reported: 2004-10-06 21:27 UTC by Harald Anlauf
Modified: 2005-04-20 06:51 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-03-16 13:23:58


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Harald Anlauf 2004-10-06 21:27:30 UTC
Hi,

I get strange output with gfortran and g77 with the following code:

      write (*,'(3p,2e15.3)') 0.0, 1.0
      end

Running the g77 compiled code gives:

      000.0E+00      100.0E-02

while the gfortran compiled code gives:

      000.0E-03      100.0E-02

While the second number (1.0) prints OK in both cases,
the first (0.0) looks really strange to me.  Other compilers give:

        0.0E+00      100.0E-02

which looks most natural to me.

I cannot find anything in the standard prohibiting the result of g77
or even that of gfortran, but I consider both as "surprising".

Cheers,
-ha
Comment 1 Volker Reichelt 2004-10-07 13:07:22 UTC
I just checked some more compilers:

MIPSpro Compilers: Version 7.4
f77:
      000.0E+00      100.0E-02
f90:
      0.000E+00      100.0E-02


Intel, Version 8.1:
      0.000E+00      100.0E-02
Comment 2 Tobias Schlüter 2005-03-13 19:13:33 UTC
This bug is still present.

I'm adding FX Coudert to the CC list, because I committed a patch by him which,
IIUC, should have fixed this, as I would have thought that this is a duplicate
of PR20101.  Maybe he has some input.
Comment 3 Francois-Xavier Coudert 2005-03-16 13:23:58 UTC
I'm working on this one. I really think PR20480 is a duplicate of this one, by
the way.
Comment 4 Harald Anlauf 2005-03-16 13:50:38 UTC
(In reply to comment #3)
> I really think PR20480 is a duplicate of this one, by
> the way.

In theory: no. AFAIK the ES edit descriptor is not part of
standard F77, and it is not implemented in either f2c or g77.
g77 refuses ES at compile time.  IBM's xlf flags it as an extension.

The P edit descriptor was already contained in standard F77.

But in practice you're right.  The fixes to PR 20480 and
the present one will be strongly intertwined...

Good luck,
-ha
Comment 5 Francois-Xavier Coudert 2005-03-16 14:02:16 UTC
Tobias, are you sure this one isn't fixed? The following looks OK to me:

$ cat pr17871.f 
      write (*,'(3p,2e15.3)') 0.0, 1.0
      write (*,'(4p,2e15.3)') 0.0, 1.0
      end
$ ~/irun/bin/gfortran -static pr17871.f && ./a.out
      000.0E+00      100.0E-02
      0000.E+00      1000.E-03
$ ~/irun/bin/gfortran -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../gcc/configure --prefix=/tmp/gfortran-20050316/irun
--enable-languages=c,f95
Thread model: posix
gcc version 4.1.0 20050316 (experimental)
Comment 6 Tobias Schlüter 2005-03-16 14:24:37 UTC
Oops, looks like I didn't test with an up-to-date library.  Yes, it looks like
this is fixed.  On the other hand the testcase in PR 20480 still gives me the
wrong result
    0.000E-01
Comment 7 Francois-Xavier Coudert 2005-04-20 06:51:02 UTC
On i386-linux, PR 20480 is fixed (see below). If you can confirm on a fresh
built that it is not, please reopen it and state what your platform is.

$ cat a.f
      write (*,10) 0.0
 10   format (ES12.3)
      end
$ gfortran a.f && ./a.out 
   0.000E+00
$ gfortran -v
Using built-in specs.
Target: i386-linux
Configured with: ../gcc/configure --prefix=/tmp/gfortran-20050419/irun
--enable-languages=c,f95 --host=i386-linux
Thread model: posix
gcc version 4.1.0 20050419 (experimental)