Bug#538019: gcc-4.2: -f no-strict-overflow causes bad code generation
Package: gcc-4.2
Version: 4.2.4-6
Severity: important
Tags: fixed-upstream
gcc 4.2.4-6 generates bad code when -f no-strict-overflow is used.
This causes kernel 2.6.27.27 and 2.6.30.2 to be miscompiled and hang. It
may be a cause of suble errors elsewhere in the kernel, too.
I don't know if the pattern of code that triggers the problem is common
in userspace.
gcc 4.3.2-1.1 doesn't exibit the bug, so it is already fixed upstream,
but probably not in the 4.2 branch.
Refer to http://lkml.org/lkml/2009/7/21/493 for details.
Refer to http://lkml.org/lkml/2009/7/22/181 for a minimal test case.
--- Test case by Krzysztof Oledzki, from the link above: ---
--- fno-strict-overflow-fixed-bug.c ---
#include <stdio.h>
int main() {
unsigned char i;
for (i = 0; i < 128; i++)
printf("loop %u\n", i);
return 0;
}
--- cut here ---
The code should be compiled with:
cc -o fno-strict-overflow-fixed-bug -Os -fno-strict-overflow fno-strict-overflow-fixed-bug.c
or:
cc -o fno-strict-overflow-fixed-bug -O2 -fno-strict-overflow fno-strict-overflow-fixed-bug.c
This bug does not exist with -O1 or if the loop is controlled by
"i < 127" or "i < 129".
---------------------------------------------------------------
-- System Information:
Debian Release: 5.0.2
APT prefers stable
APT policy: (500, 'stable')
Architecture: i386 (i686)
Kernel: Linux 2.6.29.6-t43 (PREEMPT)
Locale: LANG=pt_BR.ISO-8859-1, LC_CTYPE=pt_BR.ISO-8859-1 (charmap=ISO-8859-1)
Shell: /bin/sh linked to /bin/dash
Versions of packages gcc-4.2 depends on:
ii binutils 2.18.1~cvs20080103-7 The GNU assembler, linker and bina
ii cpp-4.2 4.2.4-6 The GNU C preprocessor
ii gcc-4.2-base 4.2.4-6 The GNU Compiler Collection (base
ii libc6 2.7-18 GNU C Library: Shared libraries
ii libgcc1 1:4.3.2-1.1 GCC support library
Versions of packages gcc-4.2 recommends:
ii libc6-dev 2.7-18 GNU C Library: Development Librari
Versions of packages gcc-4.2 suggests:
ii gcc-4.2-doc 4.2.4.nf1-3 documentation for the GNU compiler
pn gcc-4.2-locales <none> (no description available)
pn gcc-4.2-multilib <none> (no description available)
pn libgcc1-dbg <none> (no description available)
pn libgomp1-dbg <none> (no description available)
pn libmudflap0-4.2-dev <none> (no description available)
pn libmudflap0-dbg <none> (no description available)
-- no debconf information
Reply to: