public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "kargl at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/50790] ICE in copy_constant on divide by expression that evaluates to zero
Date: Wed, 19 Oct 2011 17:55:00 -0000	[thread overview]
Message-ID: <bug-50790-4-mfoWY1VRZq@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-50790-4@http.gcc.gnu.org/bugzilla/>

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

kargl at gcc dot gnu.org changed:

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

--- Comment #2 from kargl at gcc dot gnu.org 2011-10-19 17:54:31 UTC ---
Here's a variation on the original code, which removes
the print statement.  One does not need to wade through
gfortran IO structure.

program test
   implicit none
   integer i
   i = 3
   call foo (3 / (i - i))
end program test

subroutine foo(j)
  j = j * 1
end subroutine foo

The dump shows

foo (integer(kind=4) & restrict j)
{
  *j = NON_LVALUE_EXPR <*j>;
}


test ()
{
  integer(kind=4) i;

  i = 3;
  {
    static integer(kind=4) C.1729 = 3 / 0;

    foo (&C.1729);
  }
}


An equivalent C program compiles and gives a nearly identical
dump, but dies with a Floating exception(?)

troutmask:sgk[247] cat dw.c
void
foo (int *j)
{
  *j = *j * 2;
}

int
main()
{
  static int i = 3;
  i = 3 / (i - i);
  foo(&i);
  return 0;
}
troutmask:sgk[248] ~/work/4x/bin/gcc -o z dw.c && ./z
Floating exception (core dumped)


  parent reply	other threads:[~2011-10-19 17:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-19 11:41 [Bug fortran/50790] New: " jonathan.hogg at stfc dot ac.uk
2011-10-19 15:24 ` [Bug middle-end/50790] " burnus at gcc dot gnu.org
2011-10-19 17:55 ` kargl at gcc dot gnu.org [this message]
2021-12-19  4:17 ` pinskia 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-50790-4-mfoWY1VRZq@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).