Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!bob From: bob@cis.ohio-state.edu (Bob Sutterfield) Newsgroups: gnu.gcc.bug Subject: alleged GCC 1.35 float bug on SUN Message-ID: <53091@tut.cis.ohio-state.edu> Date: 27 Jun 89 18:39:11 GMT Sender: bob@tut.cis.ohio-state.edu Lines: 242 Date: Tue, 27 Jun 89 10:47:23 -0700 From: wilson@ucbarpa.Berkeley.EDU (James E. Wilson) From: bob@tinman.cis.ohio-state.edu (Bob Sutterfield) Date: 27 Jun 89 15:26:57 GMT Newsgroups: gnu.gcc.bug GNU CC 1.35 Sun3/OS3.5.1 no -g no -O const & double OK, float bad -O -g const & double OK, float bad I tried the same test on my Sun 3/50, running somewhere about OS3.4, and had no problems. All of the above cases worked for me. Perhaps there is something different in your environment that is causing the problem? Some additional info that would help solve the problem: 1) Do you still get errors after fixing the bugs in the program? Note that the first two printf statements should be "le" and "lf" respectively, instead of "e" and "f". This error could be messing up the stack, or confusing your printf routine. 2) What is the assembly produced by the compiler? Looking at the assembly output is the only way to prove that the compiler is a fault. 3) What is the output produced by -v? Namely, what assembler/ld are you using? Was gcc compiled by itself? If you are using GAS, maybe it is a bug in GAS? Here's the info you wanted, in the form of a dreaded monster typescript. I haven't read much assembly code since the Z80/6800 era, so I won't be much use in figuring stuff out at this level. Our GAS is "Gnu assembler version 1.33 (I guess.)". Karl got 1.34 while I was out of town, and I didn't notice it had arrived. Our GLD is even older, dated 14 Sep 1988 - similarly, I've been remiss in not installing the 5 April version. I'll get around to installing them both Real Soon Now, and see if that makes a difference. Script started on Tue Jun 27 14:06:20 1989 2:06pm> cat test2.c /* This is a test for floating point arithmetic by Douglas Yarrington (yarringt@cis.ohio-state.edu) (with a couple of printf nits changed) */ #include main() { double test; float test1; test = 3.1415; printf("%4.3le\n",3.1415 ); printf("%lf\n", test ); test1 = 3.1415; printf("%f\n", test1 ); } 2:06pm> gcc -v -S -g test2.c gcc version 1.35 /usr/local/lib/gcc-cpp -v -undef -D__GNUC__ -Dmc68000 -Dsun -Dunix -D__mc68000__ -D__sun__ -D__unix__ -D__HAVE_68881__ -Dmc68020 test2.c /tmp/cca12828.cpp GNU CPP version 1.35 /usr/local/lib/gcc-cc1 /tmp/cca12828.cpp -quiet -dumpbase test2.c -g -version -o test2.s GNU C version 1.35 (68k, MIT syntax) compiled by GNU C version 1.35. 2:06pm> cat test2.s #NO_APP gcc_compiled.: .stabs "test2.c",100,0,0,Ltext Ltext: .stabs "int:t1=r1;-2147483648;2147483647;",128,0,0,0 .stabs "char:t2=r2;0;127;",128,0,0,0 .stabs "long int:t3=r1;-2147483648;2147483647;",128,0,0,0 .stabs "unsigned int:t4=r1;0;-1;",128,0,0,0 .stabs "long unsigned int:t5=r1;0;-1;",128,0,0,0 .stabs "short int:t6=r1;-32768;32767;",128,0,0,0 .stabs "long long int:t7=r1;0;-1;",128,0,0,0 .stabs "short unsigned int:t8=r1;0;65535;",128,0,0,0 .stabs "long long unsigned int:t9=r1;0;-1;",128,0,0,0 .stabs "signed char:t10=r1;-128;127;",128,0,0,0 .stabs "unsigned char:t11=r1;0;255;",128,0,0,0 .stabs "float:t12=r1;4;0;",128,0,0,0 .stabs "double:t13=r1;8;0;",128,0,0,0 .stabs "long double:t14=r1;8;0;",128,0,0,0 .stabs "void:t15=15",128,0,0,0 .text .even LC0: .double 0r3.14150000000000020000e+00 LC1: .ascii "%4.3le\12\0" LC2: .ascii "%lf\12\0" .even LC3: .single 0r3.14150000000000020000e+00 LC4: .ascii "%f\12\0" .even .globl _main _main: .stabd 68,0,9 link a6,#-12 LBB2: .stabd 68,0,13 movel LC0,a6@(-8) movel LC0+4,a6@(-4) .stabd 68,0,14 movel LC0+4,sp@- movel LC0,sp@- pea LC1 jbsr _printf .stabd 68,0,15 movel a6@(-4),sp@- movel a6@(-8),sp@- pea LC2 jbsr _printf .stabd 68,0,16 movel LC3,a6@(-12) .stabd 68,0,17 fmoves a6@(-12),fp0 fmoved fp0,sp@- movel sp@+,d0 movel sp@+,d1 movel d1,sp@- movel d0,sp@- pea LC4 jbsr _printf LBE2: .stabd 68,0,18 L1: unlk a6 rts .stabs "_iobuf:T16=s20_cnt:1,0,32;_ptr:17=*11,32,32;\\",128,0,0,0 .stabs "_base:17,64,32;_bufsiz:1,96,32;_flag:6,128,16;\\",128,0,0,0 .stabs "_file:2,144,8;;",128,0,0,0 .stabs "main:F1",36,0,0,_main .stabs "test:13",128,0,0,-8 .stabs "test1:12",128,0,0,-12 .stabn 192,0,0,LBB2 .stabn 224,0,0,LBE2 2:06pm> gcc -O -v -S -g test2.c gcc version 1.35 /usr/local/lib/gcc-cpp -v -undef -D__GNUC__ -Dmc68000 -Dsun -Dunix -D__mc68000__ -D__sun__ -D__unix__ -D__OPTIMIZE__ -D__HAVE_68881__ -Dmc68020 test2.c /tmp/cca12832.cpp GNU CPP version 1.35 /usr/local/lib/gcc-cc1 /tmp/cca12832.cpp -quiet -dumpbase test2.c -g -O -version -o test2.s GNU C version 1.35 (68k, MIT syntax) compiled by GNU C version 1.35. 2:06pm> cat test2.s #NO_APP gcc_compiled.: .stabs "test2.c",100,0,0,Ltext Ltext: .stabs "int:t1=r1;-2147483648;2147483647;",128,0,0,0 .stabs "char:t2=r2;0;127;",128,0,0,0 .stabs "long int:t3=r1;-2147483648;2147483647;",128,0,0,0 .stabs "unsigned int:t4=r1;0;-1;",128,0,0,0 .stabs "long unsigned int:t5=r1;0;-1;",128,0,0,0 .stabs "short int:t6=r1;-32768;32767;",128,0,0,0 .stabs "long long int:t7=r1;0;-1;",128,0,0,0 .stabs "short unsigned int:t8=r1;0;65535;",128,0,0,0 .stabs "long long unsigned int:t9=r1;0;-1;",128,0,0,0 .stabs "signed char:t10=r1;-128;127;",128,0,0,0 .stabs "unsigned char:t11=r1;0;255;",128,0,0,0 .stabs "float:t12=r1;4;0;",128,0,0,0 .stabs "double:t13=r1;8;0;",128,0,0,0 .stabs "long double:t14=r1;8;0;",128,0,0,0 .stabs "void:t15=15",128,0,0,0 .text LC0: .ascii "%4.3le\12\0" LC1: .ascii "%lf\12\0" LC2: .ascii "%f\12\0" .even .globl _main _main: .stabd 68,0,9 link a6,#0 moveml #0x3020,sp@- LBB2: .stabd 68,0,13 movel #1074340298,d2 movel #-1065151889,d3 .stabd 68,0,14 movel d3,sp@- movel d2,sp@- pea LC0 lea _printf,a2 jbsr a2@ .stabd 68,0,15 movel d3,sp@- movel d2,sp@- pea LC1 jbsr a2@ .stabd 68,0,16 .stabd 68,0,17 fmoves #0r3.1415,fp0 fmoved fp0,sp@- pea LC2 jbsr a2@ LBE2: .stabd 68,0,18 moveml a6@(-12),#0x40c unlk a6 rts .stabs "_iobuf:T16=s20_cnt:1,0,32;_ptr:17=*11,32,32;\\",128,0,0,0 .stabs "_base:17,64,32;_bufsiz:1,96,32;_flag:6,128,16;\\",128,0,0,0 .stabs "_file:2,144,8;;",128,0,0,0 .stabs "main:F1",36,0,0,_main .stabs "test:r13",64,0,0,2 .stabn 192,0,0,LBB2 .stabn 224,0,0,LBE2 2:13pm> gcc -O -v -g -o test2-gccOg test2.c gcc version 1.35 /usr/local/lib/gcc-cpp -v -undef -D__GNUC__ -Dmc68000 -Dsun -Dunix -D__mc68000__ -D__sun__ -D__unix__ -D__OPTIMIZE__ -D__HAVE_68881__ -Dmc68020 test2.c /tmp/cca12844.cpp GNU CPP version 1.35 /usr/local/lib/gcc-cc1 /tmp/cca12844.cpp -quiet -dumpbase test2.c -g -O -version -o /tmp/cca12844.s GNU C version 1.35 (68k, MIT syntax) compiled by GNU C version 1.35. /usr/local/lib/gcc-as -mc68020 -o test2.o /tmp/cca12844.s /usr/local/lib/gcc-ld -o test2-gccOg /lib/crt0.o /lib/Mcrt1.o test2.o /usr/local/lib/gcc-gnulib -lg -lc 2:14pm> ./test2-gccOg 3.142e+00 3.141500 0.000000 2:14pm> gcc -v -g -o test2-gccg test2.c gcc version 1.35 /usr/local/lib/gcc-cpp -v -undef -D__GNUC__ -Dmc68000 -Dsun -Dunix -D__mc68000__ -D__sun__ -D__unix__ -D__HAVE_68881__ -Dmc68020 test2.c /tmp/cca12850.cpp GNU CPP version 1.35 /usr/local/lib/gcc-cc1 /tmp/cca12850.cpp -quiet -dumpbase test2.c -g -version -o /tmp/cca12850.s GNU C version 1.35 (68k, MIT syntax) compiled by GNU C version 1.35. /usr/local/lib/gcc-as -mc68020 -o test2.o /tmp/cca12850.s /usr/local/lib/gcc-ld -o test2-gccg /lib/crt0.o /lib/Mcrt1.o test2.o /usr/local/lib/gcc-gnulib -lg -lc 2:14pm> ./test2-gccg 0.000e+00 0.000000 0.000000 2:14pm> exit script done on Tue Jun 27 14:14:47 1989