From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1867 invoked by alias); 24 Jan 2014 20:49:28 -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 1820 invoked by uid 48); 24 Jan 2014 20:49:24 -0000 From: "su at cs dot ucdavis.edu" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/59932] spurious undefined behavior warning on valid code Date: Fri, 24 Jan 2014 20:49: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: su at cs dot ucdavis.edu X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- 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: 2014-01/txt/msg02633.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59932 --- Comment #4 from Zhendong Su --- (In reply to Andrew Pinski from comment #3) > (In reply to Zhendong Su from comment #2) > > (In reply to Andrew Pinski from comment #1) > > > I don't see why you think this is not undefined behavior. > > > If p1 starts at 1, it cannot turn into 0 as p1++ overflows during the > > > 2147483646th iteration. > > > > Andrew, because "d.f1 > l" is false, so the code simply returns ("return > > b;"). > > > > I also always double-check with CompCert's reference interpreter and Frama-C > > if possible. > > I see what is happening. It is a true warning that happens due to > optimizing order differences. The place we warn does not know that f is > zero the first time through the loop. Since -Os disables copy headers, we > don't get a different copy of the header. So the code does not optimize > away the header. > > This is where I am going to say there is a false positive due to optimizing. > I want to close it as won't fix because if we change the value of l to be > 0xfe, then we always warn. Andrew, sorry, I'm baffled by your comments above. Please note: 1) The issue isn't only triggered at -Os, but also at -O2 and -O3. 2) It doesn't affect GCC 4.8. 3) I don't see how changing l to 0xfe has changed anything. 4) Also optimizations shouldn't really change the warnings issued. Perhaps I have some misunderstandings, so could you clarify? Thanks.