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 <assert.h> 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