[ Reported to the Debian BTS as report #162919. Please CC 162919@bugs.debian.org on replies. Log of report can be found at http://bugs.debian.org/162919 ] Release: 3.2.1 (Debian) (Debian unstable) Environment: System: Debian GNU/Linux (unstable) Architecture: i686 [reproducible with gcc-3.2.1 20021111 and HEAD 20021103] the following simple code produces a segfault when compiled using gcc 3.2 using the folloing command line: gcc -march=k6-3 -O3 -ffast-math -funroll-loops -fomit-frame-pointer -fexpensive-optimizations -fstrict-aliasing -pipe -Wall -Werror -fno-common -o foo foo.c ---8<--- void *array[4]; int main () { int i; for (i = 0; i < sizeof (array) / sizeof (array[0]); i++) array[i] = 0; return 0; } ---8<--- The following is the resulting asm (-S instead of -o foo). Lines begining with "*" are annotations. Non-useful lines are omitted. movl $array+4, %eax movl $array, %edx cmpl $array+13, %eax movl $array+12, %ecx jb .L10 .loc 1 9 0 movl $0, (%edx) .loc 1 8 0 addl $4, %edx cmpl %ecx, %edx ja .L9 .L10: subl $array-1, %ecx shrl $4, %ecx * ^^^ set to 0 .p2align 5,,7 .L28: .loc 1 9 0 movl $0, (%edx) movl $0, 4(%edx) movl $0, 8(%edx) movl $0, 12(%edx) .loc 1 8 0 addl $16, %edx loop .L28 * ^^^ %ecx is 0 for the first pass and thus this loop becomes * effectively infinite causing %edx to overflow the array. .L9: .loc 1 10 0 ret [snip] .string "GNU C 3.2.1 20020924 (Debian prerelease)" Desired=Unknown/Install/Remove/Purge/Hold | Status=Not/Installed/Config-files/Unpacked/Failed-config/Half-installed |/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad) ||/ Name Version Description +++-==============-==============-============================================ ii binutils 2.12.90.0.1-5 The GNU assembler, linker and binary utiliti ii libc6 2.2.5-11.2 GNU C Library: Shared libraries and Timezone host: i386-linux Configured with: /home/packages/gcc/3.2/gcc-3.2-3.2.1ds5/src/configure -v --enable-languages=c,c++,java,f77,proto,objc,ada --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-gxx-include-dir=/usr/include/c++/3.2 --enable-shared --with-system-zlib --enable-nls --without-included-gettext --enable-__cxa_atexit --enable-clocale=gnu --enable-java-gc=boehm --enable-objc-gc i386-linux
Responsible-Changed-From-To: unassigned->ebotcazou Responsible-Changed-Why: Already fixed on mainline. Backporting.
State-Changed-From-To: open->closed State-Changed-Why: Fixed.
From: ebotcazou@gcc.gnu.org To: gcc-gnats@gcc.gnu.org Cc: Subject: optimization/8599 Date: 22 Nov 2002 21:20:05 -0000 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_2-branch Changes by: ebotcazou@gcc.gnu.org 2002-11-22 13:20:05 Modified files: gcc : ChangeLog doloop.c loop.c Log message: PR optimization/8599 Merge from mainline: 2002-11-04 Dale Johannesen <dalej@apple.com> * doloop.c (doloop_modify_runtime): Fix loop count computation for unrolled loops. * loop.c (loop_invariant_p): Support calling from unroller. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.13152.2.657.2.142&r2=1.13152.2.657.2.143 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/doloop.c.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.16.8.2&r2=1.16.8.3 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/loop.c.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.389.2.7.2.4&r2=1.389.2.7.2.5
State-Changed-From-To: closed->open State-Changed-Why: Reopen, backported fix From Dale causes a regression on powerpc-linux-gnu. The testcase gcc.c-torture/execute/961213-1.c now fails with -O2 -funroll-loops. Presumably the backported patch relies on some other changes in the mainline.
State-Changed-From-To: open->closed State-Changed-Why: Fixed, hopefully correctly this time.
From: ebotcazou@gcc.gnu.org To: gcc-gnats@gcc.gnu.org Cc: Subject: optimization/8599 Date: 21 Dec 2002 20:25:45 -0000 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_2-branch Changes by: ebotcazou@gcc.gnu.org 2002-12-21 12:25:44 Modified files: gcc : ChangeLog loop.c doloop.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/gcc.dg: unroll-1.c Log message: PR optimization/8599 * doloop.c (doloop_modify_runtime): Revert 2002-11-22 change. * loop.c (loop_invariant_p): Likewise. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.13152.2.657.2.165&r2=1.13152.2.657.2.166 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/loop.c.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.389.2.7.2.6&r2=1.389.2.7.2.7 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/doloop.c.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.16.8.3&r2=1.16.8.4 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.1672.2.166.2.75&r2=1.1672.2.166.2.76 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/unroll-1.c.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=NONE&r2=1.1.2.1
From: ebotcazou@gcc.gnu.org To: gcc-gnats@gcc.gnu.org Cc: Subject: optimization/8599 Date: 21 Dec 2002 20:31:16 -0000 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_2-branch Changes by: ebotcazou@gcc.gnu.org 2002-12-21 12:31:16 Modified files: gcc : ChangeLog doloop.c Log message: PR optimization/8599 * doloop.c (doloop_modify_runtime): Fix loop count computation for preconditioned unrolled loops. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.13152.2.657.2.166&r2=1.13152.2.657.2.167 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/doloop.c.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.16.8.4&r2=1.16.8.5