From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25521 invoked by alias); 8 May 2013 08:58:17 -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 25125 invoked by uid 48); 8 May 2013 08:57:45 -0000 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/57199] [4.8/4.9 Regression] Bogus warning: iteration NNNN invokes undefined behavior -Waggressive-loop-optimizations Date: Wed, 08 May 2013 08:58: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-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org 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: Status Resolution 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" MIME-Version: 1.0 X-SW-Source: 2013-05/txt/msg00490.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57199 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALID --- Comment #1 from Richard Biener 2013-05-08 08:57:45 UTC --- Note that there seems to be an error in the source: void resize(size_t n) { size_t s = size(); DestroyElements(mutable_array() + n, s - n); for the call with n == size () + 1 the function calls DestroyElements with -1U elements which we figure out and optimize the caller to : _13 = i_12 * 80; _14 = _11 + _13; Foo::~Foo (_14); i_15 = i_12 + 1; : # i_12 = PHI <0(2), i_15(3)> if (i_12 != 18446744073709551615) goto ; else goto ; which then causes the addition to overflow and invoke undefined behavior and we warn. Thus, the warning, while not 100% helpful, points at a real problem.