From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31827 invoked by alias); 8 Nov 2014 20:52:33 -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 31809 invoked by uid 48); 8 Nov 2014 20:52:29 -0000 From: "glaubitz at physik dot fu-berlin.de" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/63783] New: gcc-4.9: Miscompilation of boolean negation on SH4 using -O2 Date: Sat, 08 Nov 2014 20:52:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 4.9.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: glaubitz at physik dot fu-berlin.de 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter Message-ID: 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-11/txt/msg00559.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63783 Bug ID: 63783 Summary: gcc-4.9: Miscompilation of boolean negation on SH4 using -O2 Product: gcc Version: 4.9.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: glaubitz at physik dot fu-berlin.de Hello! Recently we ran into linker issues on our SH4 buildds in Debian [1]. We initially blamed the linker for the problem, but after some more investigation, Michael Karcher was eventually able to track down the problem being a regression in gcc [2]. When compiling the following code snippet with optimization -O2 enabled, the assertation will fail but succeed without: #include int decision_result; int truecount = 0; int val; void buggy(int flag) { int condition; if(flag == 0) condition = val != 0; else condition = !decision_result; if (condition) { truecount++; } } int main(void) { decision_result = 1; buggy(1); assert(truecount == 0); } The issue did not arise with gcc-4.6, for example, so it appears to be a regression with one of the later versions of gcc. Cheers, Adrian > [1] https://sourceware.org/bugzilla/show_bug.cgi?id=17553 > [2] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=768574