public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/19904] New: Division by zero leads to error
@ 2005-02-11 17:33 schnetter at aei dot mpg dot de
  2005-02-11 19:16 ` [Bug fortran/19904] " pinskia at gcc dot gnu dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: schnetter at aei dot mpg dot de @ 2005-02-11 17:33 UTC (permalink / raw)
  To: gcc-bugs

I want to define a parameter that contains a nan.  When I use a division by 
zero in a parameter statement, gfortran aborts with an error instead of 
setting the parameter to nan.  (The Intel Fortran compiler accepts this 
parameter statement without warning.) 
 
subroutine x 
  implicit none 
  double precision, parameter :: zero=0, nan=0/zero 
end subroutine x 
 
$ ~/gcc/bin/gfortran -c zero.f90 
 In file zero.f90:3 
 
  double precision, parameter :: zero=0, nan=0/zero 
                                             1 
Error: Division by zero at (1) 
 
$ ~/gcc/bin/gfortran --version 
GNU Fortran 95 (GCC 4.0.0 20050126 (experimental))

-- 
           Summary: Division by zero leads to error
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: schnetter at aei dot mpg dot de
                CC: gcc-bugs at gcc dot gnu dot org
 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=19904


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

* [Bug fortran/19904] Division by zero leads to error
  2005-02-11 17:33 [Bug fortran/19904] New: Division by zero leads to error schnetter at aei dot mpg dot de
@ 2005-02-11 19:16 ` pinskia at gcc dot gnu dot org
  2005-02-11 21:34 ` sgk at troutmask dot apl dot washington dot edu
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-02-11 19:16 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-02-11 13:50 -------
Confirmed.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
           Keywords|                            |rejects-valid
   Last reconfirmed|0000-00-00 00:00:00         |2005-02-11 13:50:33
               date|                            |


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


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

* [Bug fortran/19904] Division by zero leads to error
  2005-02-11 17:33 [Bug fortran/19904] New: Division by zero leads to error schnetter at aei dot mpg dot de
  2005-02-11 19:16 ` [Bug fortran/19904] " pinskia at gcc dot gnu dot org
@ 2005-02-11 21:34 ` sgk at troutmask dot apl dot washington dot edu
  2005-02-11 21:50 ` schnetter at aei dot mpg dot de
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: sgk at troutmask dot apl dot washington dot edu @ 2005-02-11 21:34 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From sgk at troutmask dot apl dot washington dot edu  2005-02-11 17:10 -------
Gfortran is a Fortran 95 compiler, and AFAIK gfortran's behavior conforms
to the Fortran 95 standard, because it has no allowance for floating point
exception.  Someday, gfortran may/will support Technical Report ISO/IEC
15580: 1998(E), which will then permit the use of the ieee_arithmetic,
ieee_features, and ieee_exceptions intrinsic modules.

If you want to set a NaN in gfortran you can do,

program test
   real nan
   integer duh
   equivalence (nan,duh)
   duh = z'FFC00000'
   print*, nan
end program test

The question then becomes "what are going to do with NaN?"
I suspect the gfortran's behavior of the numeric rational
operation and numeric binary operation may give undefined
behavior, which is again permitted by the Fortran 95 standard.

-- 


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


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

* [Bug fortran/19904] Division by zero leads to error
  2005-02-11 17:33 [Bug fortran/19904] New: Division by zero leads to error schnetter at aei dot mpg dot de
  2005-02-11 19:16 ` [Bug fortran/19904] " pinskia at gcc dot gnu dot org
  2005-02-11 21:34 ` sgk at troutmask dot apl dot washington dot edu
@ 2005-02-11 21:50 ` schnetter at aei dot mpg dot de
  2005-02-11 22:48 ` sgk at troutmask dot apl dot washington dot edu
  2005-02-11 23:42 ` pinskia at gcc dot gnu dot org
  4 siblings, 0 replies; 8+ messages in thread
From: schnetter at aei dot mpg dot de @ 2005-02-11 21:50 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From schnetter at aei dot mpg dot de  2005-02-11 17:17 -------
Actually, gfortran handles nans correctly (according to the IEEE standard) in 
all other cases.  I can e.g. generate a nan through the expression a/b, if I 
only hide from the compiler the fact that b is zero, so that it generates code 
that performs the division at run time, and does not try to evaluate it at 
compile time. 
 
Also, while your argument is correct that the Fortran 95 standard does not 
require nans to be handled correctly, your code is also undefined according to 
the Fortran 95 standard, because you use the variable "nan" without defining 
it: if you assign to an equivalenced storage an integer value, then you are 
only allowed to read out the integer value, and vice versa for the real value. 
 

-- 


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


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

* [Bug fortran/19904] Division by zero leads to error
  2005-02-11 17:33 [Bug fortran/19904] New: Division by zero leads to error schnetter at aei dot mpg dot de
                   ` (2 preceding siblings ...)
  2005-02-11 21:50 ` schnetter at aei dot mpg dot de
@ 2005-02-11 22:48 ` sgk at troutmask dot apl dot washington dot edu
  2005-02-11 23:42 ` pinskia at gcc dot gnu dot org
  4 siblings, 0 replies; 8+ messages in thread
From: sgk at troutmask dot apl dot washington dot edu @ 2005-02-11 22:48 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From sgk at troutmask dot apl dot washington dot edu  2005-02-11 17:44 -------
You are probably right that my example does not conform to the standard,
because I don't use equilance() and I whipped up the example in a minute
without inspection of its conformance.

Anyway, if you want to make gfortran accept your code, constant folding
is done in arith.c.  I suggest that you add a -fallow_inf_nan option
to gfortran and make the appropriate modifications to arith.c

-- 


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


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

* [Bug fortran/19904] Division by zero leads to error
  2005-02-11 17:33 [Bug fortran/19904] New: Division by zero leads to error schnetter at aei dot mpg dot de
                   ` (3 preceding siblings ...)
  2005-02-11 22:48 ` sgk at troutmask dot apl dot washington dot edu
@ 2005-02-11 23:42 ` pinskia at gcc dot gnu dot org
  4 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-02-11 23:42 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement


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


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

* [Bug fortran/19904] Division by zero leads to error
       [not found] <bug-19904-7427@http.gcc.gnu.org/bugzilla/>
  2006-06-08  1:17 ` jvdelisle at gcc dot gnu dot org
@ 2006-06-18  6:42 ` jvdelisle at gcc dot gnu dot org
  1 sibling, 0 replies; 8+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2006-06-18  6:42 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from jvdelisle at gcc dot gnu dot org  2006-06-18 06:42 -------
Subject: Bug 19904

Author: jvdelisle
Date: Sun Jun 18 06:42:26 2006
New Revision: 114753

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=114753
Log:
2006-06-18  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

        PR fortran/19310
        PR fortran/19904
        * gfortran.dg/real_const_3.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/real_const_3.f90
Modified:
    trunk/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug fortran/19904] Division by zero leads to error
       [not found] <bug-19904-7427@http.gcc.gnu.org/bugzilla/>
@ 2006-06-08  1:17 ` jvdelisle at gcc dot gnu dot org
  2006-06-18  6:42 ` jvdelisle at gcc dot gnu dot org
  1 sibling, 0 replies; 8+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2006-06-08  1:17 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from jvdelisle at gcc dot gnu dot org  2006-06-08 01:10 -------
This bug is related to 19310


-- 

jvdelisle at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  BugsThisDependsOn|                            |19310
   Target Milestone|---                         |4.2.0


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


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

end of thread, other threads:[~2006-06-18  6:42 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-02-11 17:33 [Bug fortran/19904] New: Division by zero leads to error schnetter at aei dot mpg dot de
2005-02-11 19:16 ` [Bug fortran/19904] " pinskia at gcc dot gnu dot org
2005-02-11 21:34 ` sgk at troutmask dot apl dot washington dot edu
2005-02-11 21:50 ` schnetter at aei dot mpg dot de
2005-02-11 22:48 ` sgk at troutmask dot apl dot washington dot edu
2005-02-11 23:42 ` pinskia at gcc dot gnu dot org
     [not found] <bug-19904-7427@http.gcc.gnu.org/bugzilla/>
2006-06-08  1:17 ` jvdelisle at gcc dot gnu dot org
2006-06-18  6:42 ` jvdelisle 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).