Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!watnot!watmum!rmariani From: rmariani@watmum.UUCP Newsgroups: comp.sys.amiga Subject: Major bug in Aztec C V3.20 Message-ID: <716@watmum.UUCP> Date: Thu, 4-Dec-86 00:21:18 EST Article-I.D.: watmum.716 Posted: Thu Dec 4 00:21:18 1986 Date-Received: Thu, 4-Dec-86 04:42:23 EST Distribution: net Organization: U of Waterloo, Ontario Lines: 58 Watch out for this one folks... it bit me pretty hard In a for loop where the initialiation is constant e.g. for (i=0;i<200;i++) { ... } The good folks at Aztec do the initial check at compile time and determine that the test can be made at the end of the loop thus saving a branch. The machine code looks like this set i=0 LOOP do the code increment i compare against 200 branch if less than to the LOOP This is swell... however it isn't smart enough, on a loop like this for (i=200;--i>=0;) { ... } It generates code of the same form!!!!! but that means that the first time it enters the loop i=200!!!!! That's wrong! They're gonna have to be smart enough to take side effects in the conditional into consideration. If you want to see the exact problem just compile the following: main() { int i; for (i=20;--i>=0 ;) printf("%d\n",i); } And note the results (20 is printed, it shouldn't be), then compile again with the -A and -T options and look at the assembler it generated Is there an Aztec beta tester listening??? Please, please have them fix this for version 3.40. Let me know if you read this and you're someone who can do something about it... tell me who to write to... anything... -Rico ...watmath!watmum!rmariani