From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7599 invoked by alias); 20 May 2013 08:12:55 -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 7560 invoked by uid 48); 20 May 2013 08:12:50 -0000 From: "jakub 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: Mon, 20 May 2013 08:12: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.9.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: REOPENED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.8.1 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc 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-05/txt/msg01287.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57199 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #3 from Jakub Jelinek --- I don't think the warning is bogus. At phiprop we have: long unsigned int _3; size_t _6; size_t _7; long unsigned int _8; : _6 = MEM[(const struct InlinedVector *)this_1(D)].size_; _3 = _6 + 1; ... _7 = MEM[(const struct InlinedVector *)this_1(D)].size_; if (_3 < _7) goto ; else goto ; : _8 = _7 - _3; and fre2 turns this into: _6 = MEM[(const struct InlinedVector *)this_1(D)].size_; _3 = _6 + 1; ... _7 = _6; if (_3 < _7) goto ; else goto ; : _8 = 18446744073709551615; i.e. it can't prove the following loop that uses _8 as upper bound is dead, but the loop has at that point constant bounds and triggers undefined behavior in it if executed. The loop can be only executed if foo_.size() is (size_t) -1, but if you call it with this value, you'll surely hit the undefined behavior the warning is complaining about.