[comp.sys.mac.programmer] Another MPW C 3.2final bug.

larryh@techbook.com (Larry Hutchinson) (06/21/91)

Following is the text of yet another bug report for MPW C 3.2 final.
I have decided that 3.2f is too buggy to use and am reverting to
the less buggy 3.2b6.  Gack!


***********************************


The following code:

#define CLOSE_DELTA 5
int AbsInt(int);

static int
IsClose(Point p1,Point p2)
{
	return !( (AbsInt(p1.h-p2.h) > CLOSE_DELTA) |
			(AbsInt(p1.v-p2.v) > CLOSE_DELTA) );
}

Produces the following incorrect code.


          LINK       A6,#$FFFC
          MOVE.L     D3,-(A7)
          MOVE.W     $000A(A6),D0
          EXT.L      D0
          MOVE.W     $000E(A6),D1
          EXT.L      D1
          SUB.L      D1,D0
          MOVE.L     D0,-(A7)
          JSR        AbsInt
          MOVEQ      #$05,D1
          CMP.L      D0,D1
          SLT        D0
          NEG.B      D0
          MOVE.L     D0,-$0004(A6)
          MOVE.W     $0008(A6),D0
          EXT.L      D0
          MOVE.W     $000C(A6),D1
          EXT.L      D1
          SUB.L      D1,D0
          MOVE.L     D0,-(A7)
          JSR        AbsInt
          MOVEQ      #$05,D1
          CMP.L      D0,D1
          MOVE.L     -$0004(A6),D0		<----- ERROR
          SLT        D1
          NEG.B      D1
          OR.B       D0,D1
          SEQ        D3
          NEG.B      D3
          EXTB.L     D3
          MOVE.L     D3,D0
          MOVE.L     -$0008(A6),D3
          UNLK       A6
          RTS        
          OR.W       A1,D4
          DC.W       $7343
          BGE.S      *+$0071
          DC.W       $7365
          MOVE.W     D0,D1
          DC.W       $0000 

Note that the move.l at the indicated line destroys the condition
code value from the cmp.l.

Flags:
	 -r -elems881 -mc68020 -mbg full
 
	 -opt off had no effect


***********************************

Larry Hutchinson
WaveMetrics@AppleLink.Apple.COM
or...
-- 
larryh@techbook.COM  ...!{tektronix!nosun,uunet}techbook!larryh
Public Access UNIX at (503) 644-8135 (1200/2400) Voice: +1 503 646-8257
Public Access User --- Not affiliated with TECHbooks

keith@Apple.COM (Keith Rollin) (06/24/91)

In article <1991Jun21.163520.22236@techbook.com> larryh@techbook.com (Larry Hutchinson) writes:
>
>
>Following is the text of yet another bug report for MPW C 3.2 final.
>I have decided that 3.2f is too buggy to use and am reverting to
>the less buggy 3.2b6.  Gack!
>
>
>***********************************
>
>
>The following code:
>
>#define CLOSE_DELTA 5
>int AbsInt(int);
>
>static int
>IsClose(Point p1,Point p2)
>{
>	return !( (AbsInt(p1.h-p2.h) > CLOSE_DELTA) |
>			(AbsInt(p1.v-p2.v) > CLOSE_DELTA) );
>}
>
>Produces the following incorrect code.
>
	[ buggy object code delete ]


If you use a logical or (||) instead of bitwise (|), it
seems to generate correct code.


-- 
------------------------------------------------------------------------------
Keith Rollin  ---  Apple Computer, Inc. 
INTERNET: keith@apple.com
    UUCP: {decwrl, hoptoad, nsc, sun, amdahl}!apple!keith
"But where the senses fail us, reason must step in."  - Galileo

amanda@visix.com (Amanda Walker) (06/24/91)

In article <54265@apple.Apple.COM> keith@Apple.COM (Keith Rollin) writes:

   >	return !( (AbsInt(p1.h-p2.h) > CLOSE_DELTA) |
   >			(AbsInt(p1.v-p2.v) > CLOSE_DELTA) );

   If you use a logical or (||) instead of bitwise (|), it
   seems to generate correct code.

That's a useful workaround, but it's still a bug...  MPW C has had problems
with the values of comparison expression ever since 3.0 (the switch from
Green Hills C to Apple C).  Sigh.  And no end in sight...

Grumble, grumble :).
--
Amanda Walker						      amanda@visix.com
Visix Software Inc.					...!uunet!visix!amanda
-- 
"We are confronted with insurmountable opportunities."	--Walt Kelly, "Pogo"