From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29153 invoked by alias); 27 Feb 2013 08:19:53 -0000 Received: (qmail 28957 invoked by uid 48); 27 Feb 2013 08:19:09 -0000 From: "nakacristo at hotmail dot com" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: nakacristo at hotmail dot com X-Bugzilla-Status: RESOLVED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2013-02/txt/msg02563.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D56463 --- Comment #5 from Crist=C3=B3bal Camarero = 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. Hen= ce 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 !=3D 0' to 'a_25 !=3D 1267128320', which would be c= orrect considering overflow. =46rom 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 mod= ular considerations. The ending condition and the printf are eliminated. In a la= ter 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.