Package: gcc-4.9 Version: 4.9.1-16 Severity: important The currently available version of gcc 4.9 for mips miscompiles boolean negation under certain circumstances. The assembly contains the "not" instruction, which represents bitwise negation, which is not appropriate, as both 0 and 1 get mapped to a non-zero bit-pattern, but the following check of the boolean tests it against 0.
See the attached example file. The assertion fails if compiled with -O2 but succeeds without optimization. This is actually a heavily stripped-down example of a miscompilation of binutils, making linking of most C++ programs on SH4 fail. The misbehaviour of binutils is reported in https://sourceware.org/bugzilla/show_bug.cgi?id=17553 , but this bug has been correctly rejected as it is not caused by the binutils source code. -- System Information: Debian Release: jessie/sid APT prefers unreleased APT policy: (500, 'unreleased'), (500, 'unstable') Architecture: sh4 (sh4a) Kernel: Linux 3.2.44-00829-g14e6110 (PREEMPT) Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Versions of packages gcc-4.9 depends on: ii binutils 2.24.90.20141104-1 ii cpp-4.9 4.9.1-16 ii gcc-4.9-base 4.9.1-16 ii libc6 2.19-11 ii libcloog-isl4 0.18.2-1 ii libgcc-4.9-dev 4.9.1-16 ii libgmp10 2:6.0.0+dfsg-6 ii libisl10 0.12.2-2 ii libmpc3 1.0.2-1 ii libmpfr4 3.1.2-1 ii zlib1g 1:1.2.8.dfsg-2 Versions of packages gcc-4.9 recommends: ii libc6-dev 2.19-11 Versions of packages gcc-4.9 suggests: pn gcc-4.9-doc <none> pn gcc-4.9-locales <none> pn libasan1-dbg <none> pn libatomic1-dbg <none> pn libcilkrts5-dbg <none> pn libgcc1-dbg <none> pn libgomp1-dbg <none> pn libitm1-dbg <none> pn liblsan0-dbg <none> pn libquadmath-dbg <none> pn libtsan0-dbg <none> pn libubsan0-dbg <none> -- no debconf information *** /home/glaubitz/gcctest/gccfail.c #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); } -- To UNSUBSCRIBE, email to debian-gcc-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: https://lists.debian.org/20141108131533.13423.37112.reportbug@localhost