public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "dominiq at lps dot ens.fr" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/54932] Invalid loop code generated by Fortran FE for loops with bounds in HIGH(type)
Date: Fri, 01 Feb 2013 13:59:00 -0000	[thread overview]
Message-ID: <bug-54932-4-RfwIUJpLVL@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-54932-4@http.gcc.gnu.org/bugzilla/>


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

--- Comment #12 from Dominique d'Humieres <dominiq at lps dot ens.fr> 2013-02-01 13:59:11 UTC ---
(In reply to comment #11)
> > > Thus, I close the bug as INVALID.
> > ... in wich case could you, please, update the testcase to be valid and remove
> > the XFAIL I introduced?
>
> We jump through some hoops in or DO loop code generation to execute
> a loop until HUGE(i) in a way that somebody who did not read the
> standard well might expect, but which is actually invalid.
>
> If we do not do this any more, then we can probably simplify our DO
> loops considerably.

This is probably too late for 4.8.0. The following patch takes advantage of the
new option -fno-aggressive-loop-optimizations to remove the xfail (and the two
XPASS at -O0 and -O1):

--- /opt/gcc/_gcc_clean/gcc/testsuite/gfortran.dg/do_1.f90    2012-10-18
00:34:47.000000000 +0200
+++ /opt/gcc/work/gcc/testsuite/gfortran.dg/do_1.f90    2013-01-31
22:02:16.000000000 +0100
@@ -1,5 +1,5 @@
-! { dg-do run { xfail *-*-* } }
-! XFAIL is tracked in PR 54932
+! { dg-do run }
+! { dg-additional-options "-fno-aggressive-loop-optimizations" }
 ! Program to check corner cases for DO statements.
 program do_1
   implicit none

Tested on x86_64-apple-darwin10 and powerpc-apple-darwin9.

> We should also warn about invalid code in the FE.

One example is

program test_real_do
    integer n
    integer x
    n=0
    do x=0.0,10.0,0.1
        n=n+1
    end do
    print *, "N is ", n
end program test_real_do

which on x86_64-apple-darwin10 gives

Program received signal SIGFPE: Floating-point exception - erroneous arithmetic
operation.

when executed. This is due to the division by zero in

    x = 0;
    countm1.0 = 10 / 0;
    while (1)
      {
        {
          unsigned int countm1t.1;

          n = n + 1;
          L.1:;
          x = NON_LVALUE_EXPR <x>;
          countm1t.1 = countm1.0;
          countm1.0 = countm1.0 + 4294967295;
          if (countm1t.1 == 0) goto L.2;
        }
      }
    L.2:;

The FE should detect that the stride is zero and output an error.

Note that on powerpc-apple-darwin9, the same test (with the same
dump-tree-original) runs and outputs

 N is            1

!?-(


  parent reply	other threads:[~2013-02-01 13:59 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-15 11:45 [Bug fortran/54932] New: " hubicka at gcc dot gnu.org
2012-10-15 11:49 ` [Bug fortran/54932] " rguenth at gcc dot gnu.org
2012-10-16 19:26 ` burnus at gcc dot gnu.org
2012-10-17  9:23 ` rguenth at gcc dot gnu.org
2012-10-17 10:42 ` burnus at gcc dot gnu.org
2012-10-17 17:03 ` burnus at gcc dot gnu.org
2012-10-17 17:58 ` kargl at gcc dot gnu.org
2012-10-17 18:51 ` burnus at gcc dot gnu.org
2012-10-17 19:21 ` sgk at troutmask dot apl.washington.edu
2012-10-23 13:55 ` hubicka at ucw dot cz
2012-11-18 14:34 ` dominiq at lps dot ens.fr
2012-11-18 16:24 ` tkoenig at gcc dot gnu.org
2013-02-01 13:59 ` dominiq at lps dot ens.fr [this message]
2013-02-04  0:17 ` hubicka at ucw dot cz
2013-02-12 18:22 ` dominiq at lps dot ens.fr
2013-03-18 10:19 ` ro at gcc dot gnu.org
2013-03-18 11:05 ` hubicka at ucw dot cz
2013-03-20 11:39 ` burnus at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-54932-4-RfwIUJpLVL@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).