Package: gcc-3.2
Version: 1:3.2.1-0pre3
Severity: important
Tags: upstream
-- System Information:
Debian Release: testing/unstable
Architecture: i386
Kernel: Linux rusalka 2.4.20-pre4 #1 SMP Tue Sep 3 22:12:35 MDT 2002 i686
Locale: LANG=C, LC_CTYPE=C
Versions of packages gcc-3.2 depends on:
ii binutils 2.13.90.0.4-1 The GNU assembler, linker and bina
ii cpp-3.21:3.2.1-0pre3 The GNU C preprocessor.
ii gcc-3.2-base 1:3.2.1-0pre3 The GNU Compiler Collection (base
ii libc6 2.2.5-14.3GNU C Library: Shared libraries an
ii libgcc11:3.2.1-0pre3 GCC support library.
-- no debconf information
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)"