public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "nakacristo at hotmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/56463] infinite loop when having integer overflow in a simple accumulator
Date: Wed, 27 Feb 2013 08:19:00 -0000	[thread overview]
Message-ID: <bug-56463-4-JW1olteIBg@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-56463-4@http.gcc.gnu.org/bugzilla/>


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

--- Comment #5 from Cristóbal Camarero <nakacristo at hotmail dot com> 2013-02-27 08:19:04 UTC ---
Dominique, I think the test I found is more problematic than yours. Since in
mine, the huge value is completely independent of the ending condition. Hence
most people would expect the loop to end without care of what happens to the
accumulator variable 'a'.

Exploring the intermediate steps of my test (with gcc test.c -O2
-fdump-tree-all) I see that in test.c.119t.ivopts the condition of the loop is
changed from 'ivtmp.8_3 != 0' to 'a_25 != 1267128320', which would be correct
considering overflow.
From here the situation must be similar to Dominique's examples.
In test.c.123t.vrp2 we see that the Value Range Propagation has decided that
the ending condition never happens, probably because the ranges have no modular
considerations. The ending condition and the printf are eliminated. In a later
stage the infinite loop is substituted by an empty infinite loop.

I suppose that this is not technically a bug. However, the lack of warning IS a
bug.
And a coherent behaviour would still being a good enhancement.


  parent reply	other threads:[~2013-02-27  8:19 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-26 16:06 [Bug c/56463] New: " nakacristo at hotmail dot com
2013-02-26 16:16 ` [Bug c/56463] " jakub at gcc dot gnu.org
2013-02-26 17:40 ` nakacristo at hotmail dot com
2013-02-26 17:54 ` jakub at gcc dot gnu.org
2013-02-26 18:42 ` dominiq at lps dot ens.fr
2013-02-27  8:19 ` nakacristo at hotmail dot com [this message]
2013-02-27  8:31 ` jakub at gcc dot gnu.org
2013-12-02 19:03 ` Joost.VandeVondele at mat dot ethz.ch
2013-12-02 19:04 ` Joost.VandeVondele at mat dot ethz.ch

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-56463-4-JW1olteIBg@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).