home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / sys / mac / programm / 21133 < prev    next >
Encoding:
Text File  |  1993-01-10  |  1.4 KB  |  39 lines

  1. Newsgroups: comp.sys.mac.programmer
  2. Path: sparky!uunet!gumby!wupost!csus.edu!netcom.com!ray
  3. From: ray@netcom.com (Ray Fischer)
  4. Subject: Re: THINK C 5.04 bug, or is it me?
  5. Message-ID: <1993Jan10.194412.10968@netcom.com>
  6. Organization: Netcom. San Jose, California
  7. References: <Arne.Venstad-080193101130@mac-df04.er.sintef.no>
  8. Date: Sun, 10 Jan 1993 19:44:12 GMT
  9. Lines: 28
  10.  
  11. Arne.Venstad@DELAB.SINTEF.no (Arne Venstad) writes ...
  12. >Dear net friends,
  13.  
  14. Dude!
  15.  
  16. >After going from THINK C 4.05 to THINK C 5.04 my XFCN started to execute
  17. >erroneously. Parts of my code:
  18. [...]
  19. > *target--=*target;    /* make a block move on overlapping areas. */
  20.  
  21. Right off this is a problem, or at least really bad C code.  The
  22. problem is that the order of execution for the various bits is NOT
  23. DEFINED.  It is perfectly legal for a C compiler to turn this into an
  24. equivalent 
  25.     *target = *target;
  26.     target--;
  27. And, not too surprisingly, this is exactly what is happening.  Since
  28. is it more efficient (in the general case) the better code generator
  29. of Think C 5.0 does what is faster.  Rather than loading the address
  30. from memory twice (as did Think C 4.0), the new code generator only
  31. loads it from memory once.
  32.  
  33. You needs to rework the code so that it doesn't depend on the order
  34. of execution, presumably by using two pointers.
  35.  
  36. -- 
  37. Ray Fischer                   "Convictions are more dangerous enemies of truth
  38. ray@netcom.com                 than lies."  -- Friedrich Nietszsche
  39.