Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!rutgers!usc!polyslo!vlsi3b15!lehi3b15!wdimm From: wdimm@lehi3b15.csee.Lehigh.EDU (William Dimm) Newsgroups: comp.sys.amiga.tech Subject: Re: HELP!!! - C bug? Summary: The verdict on this problem Keywords: HELP C Message-ID: <598@lehi3b15.csee.Lehigh.EDU> Date: 11 Jul 89 00:29:26 GMT References: <596@lehi3b15.csee.Lehigh.EDU> Organization: CSEE Dept. Lehigh University, Bethlehem, PA Lines: 46 First, I would like to thank everyone who responded to my plea for help. The final, definitive answer to the problem is this: Lattice 5.02 screwed up (as I suspected). I figured out what each of the Assembly lines does by using CPR to check the registers after executing each line. Also, someone who sent me a response came to exactly the same conclusion. The translation of each line is under it: 748: bytes -= (unsigned int)(op_count - result->ops) 00C7F888: MOVE.L 056A(A4),D0 Move contents of op_count (an address) to D0 00C7F88C: MOVE.L D0,D1 Copy contents of D0 to D1 00C7F88E: MOVEA.L FFF8(A5),A0 Move address of result->ops to A0 00C7F892: SUB.L (A0),D1 Subtract value pointed to by A0 from contents of D1 and store result in D1 00C7F894: MOVEQ #0A,D2 Move hex A (decimal 10) into D2 (this is the size of the structs pointed to) 00C7F896: DIVS.W D2,D1 Divide contents of D1 by D2, and store the result in D1 00C7F898: SUB.L D0,FFAA(A5) Subtract the contents of D0 from contents of 'bytes' and store in 'bytes' So, if you were paying attention, you noticed that the last line of Assemler is quite 'out-of-whack' with everything else that is going on. It is subtracting D0, which is op_count (a pointer) from 'bytes' rather than subtracting the difference which it computed and put in D1. The last line of Assembly should have been: 00C7F898: SUB.L D1,FFAA(A5) The C line which caused the problem was followed by: bytes *= sizeof(struct op_type); /* the structs being pointed to */ memcpy(address1,address2,bytes); /* visit the GURU */ The problem which I had doesn't occur in all cases where pointers are being subtracted (I couldn't replicate it with a small program), so it appears that something special had to happen to confuse the compiler. I notified Lattice of this problem. If anyone has any of the patches (greater than 5.02) which might fix this, please, PLEASE send them to me! Finally, the mystery is over, this thread is dead... Thanks, Bill Dimm wdimm@lehi3b15.csee.Lehigh.EDU or wcd0@lehigh.BITNET