adam@UUNET.UU.NET (Adam R de Boor) (11/12/88)
the following program (based on a piece of gdb): struct ick { int a, b, c; }; extern struct ick foop(); main() { struct ick beep; while(1) { beep = foop(); if (beep.a == 0) { break; } } } generates the following (non-optimized) code: .globl fltused .stabs "q.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 .align 1 .globl _main _main: .stabd 68,0,4 link a6,#-12 LBB2: .stabd 68,0,7 L2: .stabd 68,0,8 moveq #-12,d0 addl a6,d0 movel d0,a1 jbsr _foop .stabd 68,0,9 tstl a6@(0,d0:l*1) # ICK! d0 contains &beep jne L4 .stabd 68,0,10 jra L3 L4: jra L2 L3: LBE2: .stabd 68,0,13 L1: unlk a6 rts .stabs "ick:T16=s12a:1,0,32;b:1,32,32;c:1,64,32;;",128,0,0,0 .stabs "main:F1",36,0,0,_main .stabn 192,0,0,LBB2 .stabn 224,0,0,LBE2 This was compiled with gcc version 1.30 on an ISI 68020 box using the ISI assembler (not that that matters). This bug appears in both optimized and unoptimized code. I will search for it, but I know little about the optimizations gcc performs even w/o the -O flag and have yet to read the most-recent documentation on the RTL language, etc. If the call and assignment aren't in a loop, the proper code (tstl a6@(-12)) is generated. It makes no difference if the loop is non-infinite. Any help would be most appreciated. a