Juan.Leon@REDNECK.PC.CS.CMU.EDU (05/16/89)
Here's a simple program which is not compiled correctly by gcc 1.35 when
-O is specified. The same error appears on a SUN 3/50 and on a micro-VAX 3.
Below is a sample compilation and run on a sun 3/50. tm.h is linked
to tm-sun3.h and md is linked to m68k.md. The machine is running the
version of MACH shown in the sample run, but this should not matter.
Thanks,
Juan Leon jl@cs.cmu.edu
-----------------------------------
[redneck]~/gccbugs: cat gcc-bug.c
/* Gives wrong answer when compiled with gcc -O */
main () {
int row, col;
int x;
row = 0;
for (col = 0; col < 2; col++) {
x = (row+1)*2+col;
printf ("x %d\n", x);
}
}
[redneck]~/gccbugs: gcc -v -O gcc-bug.c -o gcc-bug
gcc version 1.35
/afs/.cs.cmu.edu/misc/gcc/build/obj/@sys/beta/gcc/tst/lib/gcc-cpp -v -undef -D__GNUC__ -Dmc68000 -Dsun -Dunix -D__mc68000__ -D__sun__ -D__unix__ -D__OPTIMIZE__ -D__HAVE_68881__ -Dmc68020 gcc-bug.c /tmp/cc014631.cpp
GNU CPP version 1.35
/afs/.cs.cmu.edu/misc/gcc/build/obj/@sys/beta/gcc/tst/lib/gcc-cc1 /tmp/cc014631.cpp -quiet -dumpbase gcc-bug.c -O -version -o /tmp/cc014631.s
GNU C version 1.35 (68k, MIT syntax) compiled by GNU C version 1.35.
/afs/.cs.cmu.edu/misc/gcc/build/obj/@sys/beta/gcc/tst/lib/gcc-as -mc68020 -o gcc-bug.o /tmp/cc014631.s
/afs/.cs.cmu.edu/misc/gcc/build/obj/@sys/beta/gcc/tst/lib/gcc-ld -o gcc-bug /lib/crt0.o /lib/Mcrt1.o gcc-bug.o /afs/.cs.cmu.edu/misc/gcc/build/obj/@sys/beta/gcc/tst/lib/gcc-gnulib -lc
[redneck]~/gccbugs: gcc-bug
x 2
x 2
[redneck]~/gccbugs: gcc gcc-bug.c -o gcc-bug
[redneck]~/gccbugs: gcc-bug
x 2
x 3
[redneck]~/gccbugs: gcc -O -S gcc-bug.c -o gcc.bug.s
[redneck]~/gccbugs: cat gcc-bug.s
#NO_APP
gcc_compiled.:
.text
LC0:
.ascii "x %d\12\0"
.even
.globl _main
_main:
link a6,#0
moveml #0x30,sp@-
subl a2,a2
clrl d1
addql #1,d1
movel d1,a3
lea a2@(a3:l:2),a3
L5:
movel a3,sp@-
pea LC0
jbsr _printf
addqw #8,sp
addqw #1,a2
moveq #1,d1
cmpl a2,d1
jge L5
moveml a6@(-8),#0xc00
unlk a6
rts
[redneck]~/gccbugs: version
Mach/4.3 #5.1(CS1f): Mon Feb 13 18:38:13 EST 1989; kernel/STD+S+WS (RIGEL.FAC.CS.CMU.EDU)
[redneck]~/gccbugs: host
REDNECK.PC.CS.CMU.EDU:128.2.242.26 CPU=SUN-3 OS=UNIX
[redneck]~/gccbugs:
---------------------------------------