public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/30780]  New: cpu_time produces a floating point exception when used with -O0
@ 2007-02-12 21:08 glv at maths dot otago dot ac dot nz
  2007-02-12 21:26 ` [Bug fortran/30780] " pinskia at gcc dot gnu dot org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: glv at maths dot otago dot ac dot nz @ 2007-02-12 21:08 UTC (permalink / raw)
  To: gcc-bugs

Test2.f95 has this code:
program test2
 real :: start, finish, dog
 call cpu_time(start)
 dog = 1.0
 dog = dog*dog
 call cpu_time(finish)
 print '("Time = ", f6.3, " seconds." )', finish - start
end program test2      

I compiled it with:
gfortran -O0 -ffpe-trap='precision' test2.f95

and on running got this error:
Floating point exception


-- 
           Summary: cpu_time produces a floating point exception when used
                    with -O0
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: glv at maths dot otago dot ac dot nz
GCC target triplet: x86_64-redhat-linux


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


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

* [Bug fortran/30780] cpu_time produces a floating point exception when used with -O0
  2007-02-12 21:08 [Bug fortran/30780] New: cpu_time produces a floating point exception when used with -O0 glv at maths dot otago dot ac dot nz
@ 2007-02-12 21:26 ` pinskia at gcc dot gnu dot org
  2007-02-12 21:28 ` pinskia at gcc dot gnu dot org
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-02-12 21:26 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2007-02-12 21:25 -------
*** Bug 30781 has been marked as a duplicate of this bug. ***


-- 


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


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

* [Bug fortran/30780] cpu_time produces a floating point exception when used with -O0
  2007-02-12 21:08 [Bug fortran/30780] New: cpu_time produces a floating point exception when used with -O0 glv at maths dot otago dot ac dot nz
  2007-02-12 21:26 ` [Bug fortran/30780] " pinskia at gcc dot gnu dot org
@ 2007-02-12 21:28 ` pinskia at gcc dot gnu dot org
  2007-02-13  4:26 ` kargl at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-02-12 21:28 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2007-02-12 21:28 -------
This works for me on x86 linux-gnu.


-- 


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


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

* [Bug fortran/30780] cpu_time produces a floating point exception when used with -O0
  2007-02-12 21:08 [Bug fortran/30780] New: cpu_time produces a floating point exception when used with -O0 glv at maths dot otago dot ac dot nz
  2007-02-12 21:26 ` [Bug fortran/30780] " pinskia at gcc dot gnu dot org
  2007-02-12 21:28 ` pinskia at gcc dot gnu dot org
@ 2007-02-13  4:26 ` kargl at gcc dot gnu dot org
  2007-02-13  4:32 ` [Bug libfortran/30780] " pinskia at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: kargl at gcc dot gnu dot org @ 2007-02-13  4:26 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from kargl at gcc dot gnu dot org  2007-02-13 04:26 -------
troutmask:sgk[223] gfc4x -o z -g -ffpe-trap='precision' g.f90
troutmask:sgk[224] gdb ./z
(gdb) run
Starting program: /usr/home/sgk/tmp/z 

Program received signal SIGFPE, Arithmetic exception.
0x000000000040a3b2 in *_gfortrani_cpu_time_4 (time=0x7fffffffe988)
    at ../../../gcc4x/libgfortran/intrinsics/cpu_time.c:160
160       *time = sec + usec * (GFC_REAL_4)1.e-6;

I have no idea how to fix this problem at the moment.
This is on amd64-*-freebsd.


-- 

kargl at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2007-02-13 04:26:26
               date|                            |


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


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

* [Bug libfortran/30780] cpu_time produces a floating point exception when used with -O0
  2007-02-12 21:08 [Bug fortran/30780] New: cpu_time produces a floating point exception when used with -O0 glv at maths dot otago dot ac dot nz
                   ` (2 preceding siblings ...)
  2007-02-13  4:26 ` kargl at gcc dot gnu dot org
@ 2007-02-13  4:32 ` pinskia at gcc dot gnu dot org
  2007-02-13  5:41 ` jvdelisle at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-02-13  4:32 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from pinskia at gcc dot gnu dot org  2007-02-13 04:32 -------
I have no idea how to fix this problem at the moment.

It is hard as there are no functions which convert from a floating point to an
integer that might not raise a signal.  This is why setting trapping on
precision is almost something you never want to do.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|fortran                     |libfortran


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


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

* [Bug libfortran/30780] cpu_time produces a floating point exception when used with -O0
  2007-02-12 21:08 [Bug fortran/30780] New: cpu_time produces a floating point exception when used with -O0 glv at maths dot otago dot ac dot nz
                   ` (3 preceding siblings ...)
  2007-02-13  4:32 ` [Bug libfortran/30780] " pinskia at gcc dot gnu dot org
@ 2007-02-13  5:41 ` jvdelisle at gcc dot gnu dot org
  2007-02-13  6:41 ` kargl at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2007-02-13  5:41 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from jvdelisle at gcc dot gnu dot org  2007-02-13 05:41 -------
I modified cpu_time_4 to just return some dummy values, and experimented a bit
with the test case.  When I commented out the print statement, the exception
went away.

Here is a reduced test case.

program test2
 real :: dog
 dog = 1.0
 print *, dog
end program test2   

The exception is occurring in the print statement. Nothing to do with time.

(gdb) r
Starting program: /home/jerry/prs/pr30780/a.out 

Program received signal SIGFPE, Arithmetic exception.
0x00002aaaaab2c3d9 in write_float (dtp=0x7fff52698b00, f=0x7fff52698a50, 
    source=<value optimized out>, len=<value optimized out>)
    at ../../../gcc43/libgfortran/io/write.c:366
366       if ((m > 0.0 && m < 0.1 - 0.05 / exp_d) || (m >= exp_d - 0.5 ) ||


-- 


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


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

* [Bug libfortran/30780] cpu_time produces a floating point exception when used with -O0
  2007-02-12 21:08 [Bug fortran/30780] New: cpu_time produces a floating point exception when used with -O0 glv at maths dot otago dot ac dot nz
                   ` (4 preceding siblings ...)
  2007-02-13  5:41 ` jvdelisle at gcc dot gnu dot org
@ 2007-02-13  6:41 ` kargl at gcc dot gnu dot org
  2007-02-14  0:37 ` jvdelisle at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: kargl at gcc dot gnu dot org @ 2007-02-13  6:41 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from kargl at gcc dot gnu dot org  2007-02-13 06:41 -------
(In reply to comment #5)

> The exception is occurring in the print statement. Nothing to do with time.
> 

No, there is a "problem" in cpu_time.  -ffpe-trap='precision' is
trapping on lost precision.  On x86_64, long is 64-bit and 
GFC_REAL_4 is 32-bit with only 24-bits of precision.  You can't
convert long to GFC_REAL_4 without loss of precision.  In short,
using this option is probably not a good idea if you have mixed
mode math.


-- 


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


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

* [Bug libfortran/30780] cpu_time produces a floating point exception when used with -O0
  2007-02-12 21:08 [Bug fortran/30780] New: cpu_time produces a floating point exception when used with -O0 glv at maths dot otago dot ac dot nz
                   ` (5 preceding siblings ...)
  2007-02-13  6:41 ` kargl at gcc dot gnu dot org
@ 2007-02-14  0:37 ` jvdelisle at gcc dot gnu dot org
  2007-09-21 11:37 ` [Bug libfortran/30780] FPE in CPU_TIME (and possibly others) with -ffpe-trap=underflow fxcoudert at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2007-02-14  0:37 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from jvdelisle at gcc dot gnu dot org  2007-02-14 00:37 -------
OK, then there is a similar, not necessarily related problem in write.c.


-- 


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


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

* [Bug libfortran/30780] FPE in CPU_TIME (and possibly others) with -ffpe-trap=underflow
  2007-02-12 21:08 [Bug fortran/30780] New: cpu_time produces a floating point exception when used with -O0 glv at maths dot otago dot ac dot nz
                   ` (6 preceding siblings ...)
  2007-02-14  0:37 ` jvdelisle at gcc dot gnu dot org
@ 2007-09-21 11:37 ` fxcoudert at gcc dot gnu dot org
  2007-09-21 11:45 ` burnus at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2007-09-21 11:37 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from fxcoudert at gcc dot gnu dot org  2007-09-21 11:37 -------
I'm changing this into a documentation PR, and assign it to myself. It was
decided that there really isn't a good way to provide high-quality timer
functions with precision-loss trapping. We need to document this shortcoming in
the -ffpe-trap option doc.


-- 

fxcoudert at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |fxcoudert at gcc dot gnu dot
                   |dot org                     |org
             Status|NEW                         |ASSIGNED
 GCC target triplet|x86_64-redhat-linux         |
           Keywords|                            |documentation
   Last reconfirmed|2007-02-13 04:26:26         |2007-09-21 11:37:15
               date|                            |


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


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

* [Bug libfortran/30780] FPE in CPU_TIME (and possibly others) with -ffpe-trap=underflow
  2007-02-12 21:08 [Bug fortran/30780] New: cpu_time produces a floating point exception when used with -O0 glv at maths dot otago dot ac dot nz
                   ` (7 preceding siblings ...)
  2007-09-21 11:37 ` [Bug libfortran/30780] FPE in CPU_TIME (and possibly others) with -ffpe-trap=underflow fxcoudert at gcc dot gnu dot org
@ 2007-09-21 11:45 ` burnus at gcc dot gnu dot org
  2007-09-21 11:59 ` fxcoudert at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-09-21 11:45 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from burnus at gcc dot gnu dot org  2007-09-21 11:45 -------
> We need to document this shortcoming in the -ffpe-trap option doc.
Maybe one should put it additionally also in the documentation of the CPU_TIME
intrinsic subroutine.


-- 


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


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

* [Bug libfortran/30780] FPE in CPU_TIME (and possibly others) with -ffpe-trap=underflow
  2007-02-12 21:08 [Bug fortran/30780] New: cpu_time produces a floating point exception when used with -O0 glv at maths dot otago dot ac dot nz
                   ` (8 preceding siblings ...)
  2007-09-21 11:45 ` burnus at gcc dot gnu dot org
@ 2007-09-21 11:59 ` fxcoudert at gcc dot gnu dot org
  2007-09-26 22:27 ` fxcoudert at gcc dot gnu dot org
  2007-09-26 22:28 ` fxcoudert at gcc dot gnu dot org
  11 siblings, 0 replies; 13+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2007-09-21 11:59 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from fxcoudert at gcc dot gnu dot org  2007-09-21 11:59 -------
(In reply to comment #9)
> Maybe one should put it additionally also in the documentation of the CPU_TIME
> intrinsic subroutine.

Yep, but I suspect that CPU_TIME is not the only routine library routine that
can trigger this exception. I don't feel like going through all library
routines and check which can fail, but the I/O system certainly can trigger it
also, as Jerry observed, so I was thinking of adding a more general kind of
remark.


-- 


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


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

* [Bug libfortran/30780] FPE in CPU_TIME (and possibly others) with -ffpe-trap=underflow
  2007-02-12 21:08 [Bug fortran/30780] New: cpu_time produces a floating point exception when used with -O0 glv at maths dot otago dot ac dot nz
                   ` (9 preceding siblings ...)
  2007-09-21 11:59 ` fxcoudert at gcc dot gnu dot org
@ 2007-09-26 22:27 ` fxcoudert at gcc dot gnu dot org
  2007-09-26 22:28 ` fxcoudert at gcc dot gnu dot org
  11 siblings, 0 replies; 13+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2007-09-26 22:27 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #11 from fxcoudert at gcc dot gnu dot org  2007-09-26 22:27 -------
Subject: Bug 30780

Author: fxcoudert
Date: Wed Sep 26 22:27:16 2007
New Revision: 128825

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=128825
Log:
        PR fortran/30780
        * invoke.texi: Add note to -ffpe-trap option. Fix typos.

Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/invoke.texi


-- 


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


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

* [Bug libfortran/30780] FPE in CPU_TIME (and possibly others) with -ffpe-trap=underflow
  2007-02-12 21:08 [Bug fortran/30780] New: cpu_time produces a floating point exception when used with -O0 glv at maths dot otago dot ac dot nz
                   ` (10 preceding siblings ...)
  2007-09-26 22:27 ` fxcoudert at gcc dot gnu dot org
@ 2007-09-26 22:28 ` fxcoudert at gcc dot gnu dot org
  11 siblings, 0 replies; 13+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2007-09-26 22:28 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #12 from fxcoudert at gcc dot gnu dot org  2007-09-26 22:28 -------
Documentation added.


-- 

fxcoudert at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.3.0


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


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

end of thread, other threads:[~2007-09-26 22:28 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-12 21:08 [Bug fortran/30780] New: cpu_time produces a floating point exception when used with -O0 glv at maths dot otago dot ac dot nz
2007-02-12 21:26 ` [Bug fortran/30780] " pinskia at gcc dot gnu dot org
2007-02-12 21:28 ` pinskia at gcc dot gnu dot org
2007-02-13  4:26 ` kargl at gcc dot gnu dot org
2007-02-13  4:32 ` [Bug libfortran/30780] " pinskia at gcc dot gnu dot org
2007-02-13  5:41 ` jvdelisle at gcc dot gnu dot org
2007-02-13  6:41 ` kargl at gcc dot gnu dot org
2007-02-14  0:37 ` jvdelisle at gcc dot gnu dot org
2007-09-21 11:37 ` [Bug libfortran/30780] FPE in CPU_TIME (and possibly others) with -ffpe-trap=underflow fxcoudert at gcc dot gnu dot org
2007-09-21 11:45 ` burnus at gcc dot gnu dot org
2007-09-21 11:59 ` fxcoudert at gcc dot gnu dot org
2007-09-26 22:27 ` fxcoudert at gcc dot gnu dot org
2007-09-26 22:28 ` fxcoudert 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).