public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libfortran/21376] New: libfortran "E" output format causes FPE
@ 2005-05-04  7:22 prw at ceiriog1 dot demon dot co dot uk
  2005-05-04 16:41 ` [Bug libfortran/21376] " fxcoudert at gcc dot gnu dot org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: prw at ceiriog1 dot demon dot co dot uk @ 2005-05-04  7:22 UTC (permalink / raw)
  To: gcc-bugs

There's an obvious bug in libfortran/io/write.c which causes a failure
to print "1.0" in exp. format - here's the fix:

diff -U3 -r gcc-4.0.0-old/libgfortran/io/write.c gcc-4.0.0/libgfortran/io/write.c
--- gcc-4.0.0-old/libgfortran/io/write.c        2005-04-05 15:24:36.000000000 +0100
+++ gcc-4.0.0/libgfortran/io/write.c    2005-05-04 07:55:12.000000000 +0100
@@ -316,9 +316,11 @@
     edigits = 2;
   else
     {
-      edigits = 1 + (int) log10 (fabs(log10 (value)));
-      if (edigits < 2)
+      double absexp = fabs(log10 (value));
+      if (absexp < 100)
        edigits = 2;
+      else
+       edigits = 1 + (int) log10 (absexp);
     }

   if (ft == FMT_F || ft == FMT_EN

-- 
           Summary: libfortran "E" output format causes FPE
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: libfortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: prw at ceiriog1 dot demon dot co dot uk
                CC: gcc-bugs at gcc dot gnu dot org,prw at ceiriog1 dot
                    demon dot co dot uk
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libfortran/21376] libfortran "E" output format causes FPE
  2005-05-04  7:22 [Bug libfortran/21376] New: libfortran "E" output format causes FPE prw at ceiriog1 dot demon dot co dot uk
@ 2005-05-04 16:41 ` fxcoudert at gcc dot gnu dot org
  2005-05-04 17:28 ` prw at ceiriog1 dot demon dot co dot uk
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2005-05-04 16:41 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From fxcoudert at gcc dot gnu dot org  2005-05-04 16:41 -------
I'm interested: you do have a testcase that produces this failure on
i686-pc-linux-gnu? If so, I will make a testcase out of it and propose your
patch for review...

-- 


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libfortran/21376] libfortran "E" output format causes FPE
  2005-05-04  7:22 [Bug libfortran/21376] New: libfortran "E" output format causes FPE prw at ceiriog1 dot demon dot co dot uk
  2005-05-04 16:41 ` [Bug libfortran/21376] " fxcoudert at gcc dot gnu dot org
@ 2005-05-04 17:28 ` prw at ceiriog1 dot demon dot co dot uk
  2005-05-09 11:33 ` fxcoudert at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: prw at ceiriog1 dot demon dot co dot uk @ 2005-05-04 17:28 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From prw at ceiriog1 dot demon dot co dot uk  2005-05-04 17:28 -------
The problem occurred in a large finite element analysis code I developed.
The toplevel logic was written in C++, and this was linked to a venerable
public domain numerical analysis library in Fortran.  My testcase consists
of the following two files.  You only get a floating point exception
if IEEE floating point exceptions are enabled.  I don't know if it is possible
to do this from a pure Fortran program, but it is certainly possible to
do from C, and I find it important to do this in numerical codes so that
I can see errors where they occur rather than just propagating NaN's through
the program.


File "toplevel.c":

#include <fenv.h>

main()
{
  feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW );
  killer_();
}



File "killer.f":

        subroutine killer
        write(6,'(x,e10.4)') 1.0
        end

gcc -c toplevel.c
gfortran -c killer.f
gcc toplevel.o killer.o -lgfortran
./a.out




-- 


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libfortran/21376] libfortran "E" output format causes FPE
  2005-05-04  7:22 [Bug libfortran/21376] New: libfortran "E" output format causes FPE prw at ceiriog1 dot demon dot co dot uk
  2005-05-04 16:41 ` [Bug libfortran/21376] " fxcoudert at gcc dot gnu dot org
  2005-05-04 17:28 ` prw at ceiriog1 dot demon dot co dot uk
@ 2005-05-09 11:33 ` fxcoudert at gcc dot gnu dot org
  2005-05-22 18:36 ` fxcoudert at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2005-05-09 11:33 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |fxcoudert at gcc dot gnu dot
                   |dot org                     |org
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|                            |1
  GCC build triplet|i686-pc-linux-gnu           |
   GCC host triplet|i686-pc-linux-gnu           |
 GCC target triplet|i686-pc-linux-gnu           |
   Last reconfirmed|0000-00-00 00:00:00         |2005-05-09 11:29:26
               date|                            |


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libfortran/21376] libfortran "E" output format causes FPE
  2005-05-04  7:22 [Bug libfortran/21376] New: libfortran "E" output format causes FPE prw at ceiriog1 dot demon dot co dot uk
                   ` (2 preceding siblings ...)
  2005-05-09 11:33 ` fxcoudert at gcc dot gnu dot org
@ 2005-05-22 18:36 ` fxcoudert at gcc dot gnu dot org
  2005-05-22 21:18 ` cvs-commit at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2005-05-22 18:36 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From fxcoudert at gcc dot gnu dot org  2005-05-22 18:35 -------
Patch submitted for review.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                URL|                            |http://gcc.gnu.org/ml/fortra
                   |                            |n/2005-05/msg00249.html
           Keywords|                            |patch


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libfortran/21376] libfortran "E" output format causes FPE
  2005-05-04  7:22 [Bug libfortran/21376] New: libfortran "E" output format causes FPE prw at ceiriog1 dot demon dot co dot uk
                   ` (4 preceding siblings ...)
  2005-05-22 21:18 ` cvs-commit at gcc dot gnu dot org
@ 2005-05-22 21:18 ` cvs-commit at gcc dot gnu dot org
  2005-05-22 21:21 ` fxcoudert at gcc dot gnu dot org
  2005-06-05  7:39 ` pinskia at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-05-22 21:18 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2005-05-22 21:17 -------
Subject: Bug 21376

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	fxcoudert@gcc.gnu.org	2005-05-22 21:17:43

Modified files:
	libgfortran    : ChangeLog 
	libgfortran/io : write.c 

Log message:
	PR libfortran/21376
	* io/write.c (output_float): Rework logic to avoid call to log10
	with argument equal to zero.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/ChangeLog.diff?cvsroot=gcc&r1=1.226&r2=1.227
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/io/write.c.diff?cvsroot=gcc&r1=1.37&r2=1.38


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2005-05-22 21:17 -------
Subject: Bug 21376

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-4_0-branch
Changes by:	fxcoudert@gcc.gnu.org	2005-05-22 21:17:44

Modified files:
	libgfortran    : ChangeLog 
	libgfortran/io : write.c 

Log message:
	PR libfortran/21376
	* io/write.c (output_float): Rework logic to avoid call to log10
	with argument equal to zero.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.163.2.37&r2=1.163.2.38
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/io/write.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.23.2.6&r2=1.23.2.7



-- 


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libfortran/21376] libfortran "E" output format causes FPE
  2005-05-04  7:22 [Bug libfortran/21376] New: libfortran "E" output format causes FPE prw at ceiriog1 dot demon dot co dot uk
                   ` (3 preceding siblings ...)
  2005-05-22 18:36 ` fxcoudert at gcc dot gnu dot org
@ 2005-05-22 21:18 ` cvs-commit at gcc dot gnu dot org
  2005-05-22 21:18 ` cvs-commit at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-05-22 21:18 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2005-05-22 21:17 -------
Subject: Bug 21376

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	fxcoudert@gcc.gnu.org	2005-05-22 21:17:43

Modified files:
	libgfortran    : ChangeLog 
	libgfortran/io : write.c 

Log message:
	PR libfortran/21376
	* io/write.c (output_float): Rework logic to avoid call to log10
	with argument equal to zero.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/ChangeLog.diff?cvsroot=gcc&r1=1.226&r2=1.227
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/io/write.c.diff?cvsroot=gcc&r1=1.37&r2=1.38


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2005-05-22 21:17 -------
Subject: Bug 21376

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-4_0-branch
Changes by:	fxcoudert@gcc.gnu.org	2005-05-22 21:17:44

Modified files:
	libgfortran    : ChangeLog 
	libgfortran/io : write.c 

Log message:
	PR libfortran/21376
	* io/write.c (output_float): Rework logic to avoid call to log10
	with argument equal to zero.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.163.2.37&r2=1.163.2.38
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/io/write.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.23.2.6&r2=1.23.2.7



-- 


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libfortran/21376] libfortran "E" output format causes FPE
  2005-05-04  7:22 [Bug libfortran/21376] New: libfortran "E" output format causes FPE prw at ceiriog1 dot demon dot co dot uk
                   ` (5 preceding siblings ...)
  2005-05-22 21:18 ` cvs-commit at gcc dot gnu dot org
@ 2005-05-22 21:21 ` fxcoudert at gcc dot gnu dot org
  2005-06-05  7:39 ` pinskia at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2005-05-22 21:21 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From fxcoudert at gcc dot gnu dot org  2005-05-22 21:21 -------
Fixed. Thanks for reporting!

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libfortran/21376] libfortran "E" output format causes FPE
  2005-05-04  7:22 [Bug libfortran/21376] New: libfortran "E" output format causes FPE prw at ceiriog1 dot demon dot co dot uk
                   ` (6 preceding siblings ...)
  2005-05-22 21:21 ` fxcoudert at gcc dot gnu dot org
@ 2005-06-05  7:39 ` pinskia at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-06-05  7:39 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.0.1


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2005-06-05  7:39 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-04  7:22 [Bug libfortran/21376] New: libfortran "E" output format causes FPE prw at ceiriog1 dot demon dot co dot uk
2005-05-04 16:41 ` [Bug libfortran/21376] " fxcoudert at gcc dot gnu dot org
2005-05-04 17:28 ` prw at ceiriog1 dot demon dot co dot uk
2005-05-09 11:33 ` fxcoudert at gcc dot gnu dot org
2005-05-22 18:36 ` fxcoudert at gcc dot gnu dot org
2005-05-22 21:18 ` cvs-commit at gcc dot gnu dot org
2005-05-22 21:18 ` cvs-commit at gcc dot gnu dot org
2005-05-22 21:21 ` fxcoudert at gcc dot gnu dot org
2005-06-05  7:39 ` pinskia at gcc dot gnu dot org

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).