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