From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10747 invoked by alias); 15 Oct 2013 13:27:00 -0000 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 Received: (qmail 10708 invoked by uid 55); 15 Oct 2013 13:26:57 -0000 From: "rguenther at suse dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/58143] [4.8/4.9 regression] wrong code at -O3 Date: Tue, 15 Oct 2013 13:27:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 4.8.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenther at suse dot de X-Bugzilla-Status: ASSIGNED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: rguenth at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.8.2 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: 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: 2013-10/txt/msg00903.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58143 --- Comment #25 from rguenther at suse dot de --- On Tue, 15 Oct 2013, bernd.edlinger at hotmail dot de wrote: > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58143 > > --- Comment #24 from Bernd Edlinger --- > Wall, > > the logic behind the loop niter is really strange > and the results are simply insane. > > When you consider this example: > > int a, b, c, d, e; > > int > main () > { > for (b = 4; b > -30; b--) > { > e = 2147483647 - b; > for (; c;) > for (;;) > { > if (d) > break; > } > } > return 0; > } > > then the reasoning is that an "undefined" value will > be written to e in loop iteration #4. > And therefore it does not matter what happens afterwards. > But for the result of main() which will ultimately be 0 > the undefined value of e does not matter. > > Why should a undefined value that is not used for anything > create such a problem? Because undefined behavior includes random effects (like formatting your hard drive). In this case the undefined behavior is simply assuming we never reach loop iteration #4 and thus the loop exit test is never true. Richard.