public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/61002] New: Can't divide by 0
@ 2014-04-29 13:52 fkrogh#gcc at mathalacarte dot com
  2014-04-29 14:06 ` [Bug fortran/61002] " dominiq at lps dot ens.fr
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: fkrogh#gcc at mathalacarte dot com @ 2014-04-29 13:52 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 61002
           Summary: Can't divide by 0
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fkrogh#gcc at mathalacarte dot com

If I have a statement like

real(kind(1.0d0)), parameter :: big=1.0d0/0.0d0

the compile fails with an error even when using the option -ffpe-trap=

The man page for gcc makes this excellent point

       -Wno-div-by-zero
           Do not warn about compile-time integer division by zero.  Floating-
           point division by zero is not warned about, as it can be a
           legitimate way of obtaining infinities and NaNs.

And in fact, all I'm trying to do is obtain infinity.


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

* [Bug fortran/61002] Can't divide by 0
  2014-04-29 13:52 [Bug fortran/61002] New: Can't divide by 0 fkrogh#gcc at mathalacarte dot com
@ 2014-04-29 14:06 ` dominiq at lps dot ens.fr
  2014-04-29 14:53 ` fkrogh#gcc at mathalacarte dot com
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: dominiq at lps dot ens.fr @ 2014-04-29 14:06 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Compile with -fno-range-check. Also

f951: warning: command line option '-Wno-div-by-zero' is valid for
C/C++/ObjC/ObjC++ but not for Fortran


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

* [Bug fortran/61002] Can't divide by 0
  2014-04-29 13:52 [Bug fortran/61002] New: Can't divide by 0 fkrogh#gcc at mathalacarte dot com
  2014-04-29 14:06 ` [Bug fortran/61002] " dominiq at lps dot ens.fr
@ 2014-04-29 14:53 ` fkrogh#gcc at mathalacarte dot com
  2014-05-01 22:17 ` dominiq at lps dot ens.fr
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: fkrogh#gcc at mathalacarte dot com @ 2014-04-29 14:53 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Fred Krogh <fkrogh#gcc at mathalacarte dot com> ---
Thanks, that did the job.


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

* [Bug fortran/61002] Can't divide by 0
  2014-04-29 13:52 [Bug fortran/61002] New: Can't divide by 0 fkrogh#gcc at mathalacarte dot com
  2014-04-29 14:06 ` [Bug fortran/61002] " dominiq at lps dot ens.fr
  2014-04-29 14:53 ` fkrogh#gcc at mathalacarte dot com
@ 2014-05-01 22:17 ` dominiq at lps dot ens.fr
  2014-05-01 22:22 ` fkrogh#gcc at mathalacarte dot com
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: dominiq at lps dot ens.fr @ 2014-05-01 22:17 UTC (permalink / raw)
  To: gcc-bugs

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

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING
   Last reconfirmed|                            |2014-05-01
     Ever confirmed|0                           |1

--- Comment #3 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Another way to get Infinity or NaN can be achieved with the following code
(which traps at run time when compiled with  -ffpe-trap=invalid)

real :: x, y, z
x = 0.0
y = 1.0/x
z = log(-y)
print *, y, z
end

If there is no objection I'll close this PR as INVALID in a couple of days.


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

* [Bug fortran/61002] Can't divide by 0
  2014-04-29 13:52 [Bug fortran/61002] New: Can't divide by 0 fkrogh#gcc at mathalacarte dot com
                   ` (2 preceding siblings ...)
  2014-05-01 22:17 ` dominiq at lps dot ens.fr
@ 2014-05-01 22:22 ` fkrogh#gcc at mathalacarte dot com
  2014-05-01 22:27 ` dominiq at lps dot ens.fr
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: fkrogh#gcc at mathalacarte dot com @ 2014-05-01 22:22 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Fred Krogh <fkrogh#gcc at mathalacarte dot com> ---
No objection here.  I had just missed -fno-range-check, see comment 1.


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

* [Bug fortran/61002] Can't divide by 0
  2014-04-29 13:52 [Bug fortran/61002] New: Can't divide by 0 fkrogh#gcc at mathalacarte dot com
                   ` (3 preceding siblings ...)
  2014-05-01 22:22 ` fkrogh#gcc at mathalacarte dot com
@ 2014-05-01 22:27 ` dominiq at lps dot ens.fr
  2014-05-02 12:08 ` burnus at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: dominiq at lps dot ens.fr @ 2014-05-01 22:27 UTC (permalink / raw)
  To: gcc-bugs

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

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |RESOLVED
         Resolution|---                         |INVALID

--- Comment #5 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
> No objection here.  I had just missed -fno-range-check, see comment 1.

For the record the option is documented at
http://gcc.gnu.org/onlinedocs/gfortran/Fortran-Dialect-Options.html#Fortran-Dialect-Options

-fno-range-check
Disable range checking on results of simplification of constant expressions
during compilation. For example, GNU Fortran will give an error at compile time
when simplifying a = 1. / 0. With this option, no error will be given and a
will be assigned the value +Infinity. If an expression evaluates to a value
outside of the relevant range of [-HUGE():HUGE()], then the expression will be
replaced by -Inf or +Inf as appropriate. Similarly, DATA i/Z'FFFFFFFF'/ will
result in an integer overflow on most systems, but with -fno-range-check the
value will “wrap around” and i will be initialized to -1 instead. 

Closing as INVALID.
>From gcc-bugs-return-450359-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Fri May 02 01:07:28 2014
Return-Path: <gcc-bugs-return-450359-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 2702 invoked by alias); 2 May 2014 01:07:26 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 659 invoked by uid 48); 2 May 2014 01:07:20 -0000
From: "jvdelisle at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/60956] error reading (and writing) large text files in gfortran
Date: Fri, 02 May 2014 01:07:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: fortran
X-Bugzilla-Version: 4.7.3
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: jvdelisle at gcc dot gnu.org
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: cc
Message-ID: <bug-60956-4-NRfq86l9wV@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-60956-4@http.gcc.gnu.org/bugzilla/>
References: <bug-60956-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-05/txt/msg00051.txt.bz2
Content-length: 1035

http://gcc.gnu.org/bugzilla/show_bug.cgi?id`956

Jerry DeLisle <jvdelisle at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jvdelisle at gcc dot gnu.org

--- Comment #2 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
(In reply to Dominique d'Humieres from comment #1)
> The attached test executes without error when compiled with 4.3.1 (~232s),
> but fails with all the revisions I have tried starting at 4.5 (no exhaustive
> tests). From pr44292: "gfortran currently fails if the RECL= is larger than
> 2 GB", so the failure seems expected.

I recall pr44292.  I never got a reply so I could not test the patch. I would
highly suggest using unformatted IO for these large data sets. Saves space and
runs faster, clearly.

Its been a while so I don't know if I can find that old patch. Breaking ABI is
also an issue, needing some discussion with the gfortran team.


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

* [Bug fortran/61002] Can't divide by 0
  2014-04-29 13:52 [Bug fortran/61002] New: Can't divide by 0 fkrogh#gcc at mathalacarte dot com
                   ` (4 preceding siblings ...)
  2014-05-01 22:27 ` dominiq at lps dot ens.fr
@ 2014-05-02 12:08 ` burnus at gcc dot gnu.org
  2014-05-02 14:24 ` dominiq at lps dot ens.fr
  2014-05-03  7:21 ` schwab@linux-m68k.org
  7 siblings, 0 replies; 9+ messages in thread
From: burnus at gcc dot gnu.org @ 2014-05-02 12:08 UTC (permalink / raw)
  To: gcc-bugs

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

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |burnus at gcc dot gnu.org

--- Comment #6 from Tobias Burnus <burnus at gcc dot gnu.org> ---
Regarding:

y = 1.0/0.0
       1
Error: Division by zero at (1)


I think we should do what we did elsewhere, namely:

"This check can be disabled with the option -fno-range-check"


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

* [Bug fortran/61002] Can't divide by 0
  2014-04-29 13:52 [Bug fortran/61002] New: Can't divide by 0 fkrogh#gcc at mathalacarte dot com
                   ` (5 preceding siblings ...)
  2014-05-02 12:08 ` burnus at gcc dot gnu.org
@ 2014-05-02 14:24 ` dominiq at lps dot ens.fr
  2014-05-03  7:21 ` schwab@linux-m68k.org
  7 siblings, 0 replies; 9+ messages in thread
From: dominiq at lps dot ens.fr @ 2014-05-02 14:24 UTC (permalink / raw)
  To: gcc-bugs

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

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |sgk at troutmask dot apl.washingto
                   |                            |n.edu

--- Comment #7 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
> I think we should do what we did elsewhere, namely:
>
> "This check can be disabled with the option -fno-range-check"

Along the following patch

--- ../_clean/gcc/fortran/arith.c    2014-04-27 12:52:10.000000000 +0200
+++ gcc/fortran/arith.c    2014-05-02 15:55:19.000000000 +0200
@@ -104,7 +104,8 @@ gfc_arith_error (arith code)
       p = _("Arithmetic NaN at %L");
       break;
     case ARITH_DIV0:
-      p = _("Division by zero at %L");
+      p = _("Division by zero at %L. This check "
+        "can be disabled with the option -fno-range-check");
       break;
     case ARITH_INCOMMENSURATE:
       p = _("Array operands are incommensurate at %L");
@@ -1929,7 +1930,8 @@ arith_error (arith rc, gfc_typespec *fro
          gfc_typename (from), gfc_typename (to), where);
       break;
     case ARITH_DIV0:
-      gfc_error ("Division by zero converting %s to %s at %L",
+      gfc_error ("Division by zero converting %s to %s at %L. This check "
+         "can be disabled with the option -fno-range-check",
          gfc_typename (from), gfc_typename (to), where);
       break;
     case ARITH_INCOMMENSURATE:

? This only works for floating point values:

/opt/gcc/work/gcc/testsuite/gfortran.dg/arith_divide.f:10.14:

        j = 10/0! { dg-error "Division by zero at" }                    
              1
Error: Division by zero at (1). This check can be disabled with the option
-fno-range-check

What is the best way to avoid the misleading "This check can be disabled with
the option -fno-range-check" for integers? Use "This check can be disabled for
floating point values with the option -fno-range-check"? or pass an extra
argument to gfc_arith_error?

While I am at it, should I do the same thing for "Arithmetic overflow" and
friends? Should not "This check can be disabled with the option
-fno-range-check" ends with a dot?


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

* [Bug fortran/61002] Can't divide by 0
  2014-04-29 13:52 [Bug fortran/61002] New: Can't divide by 0 fkrogh#gcc at mathalacarte dot com
                   ` (6 preceding siblings ...)
  2014-05-02 14:24 ` dominiq at lps dot ens.fr
@ 2014-05-03  7:21 ` schwab@linux-m68k.org
  7 siblings, 0 replies; 9+ messages in thread
From: schwab@linux-m68k.org @ 2014-05-03  7:21 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from Andreas Schwab <schwab@linux-m68k.org> ---
It should use the same format as the warning messages.

"Division by zero at %L [-frange-check]"


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

end of thread, other threads:[~2014-05-03  7:21 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-29 13:52 [Bug fortran/61002] New: Can't divide by 0 fkrogh#gcc at mathalacarte dot com
2014-04-29 14:06 ` [Bug fortran/61002] " dominiq at lps dot ens.fr
2014-04-29 14:53 ` fkrogh#gcc at mathalacarte dot com
2014-05-01 22:17 ` dominiq at lps dot ens.fr
2014-05-01 22:22 ` fkrogh#gcc at mathalacarte dot com
2014-05-01 22:27 ` dominiq at lps dot ens.fr
2014-05-02 12:08 ` burnus at gcc dot gnu.org
2014-05-02 14:24 ` dominiq at lps dot ens.fr
2014-05-03  7:21 ` schwab@linux-m68k.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).