Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!princeton!caip!lll-crg!seismo!munnari!moncskermit!basser!metro!ipso!runx!baron From: baron@runx.OZ (Jason Haines) Newsgroups: net.micro.mac Subject: Re: Megamax bug? Message-ID: <1250@runx.OZ> Date: Tue, 17-Jun-86 03:17:17 EDT Article-I.D.: runx.1250 Posted: Tue Jun 17 03:17:17 1986 Date-Received: Wed, 25-Jun-86 04:55:20 EDT References: <1023@k.cs.cmu.edu> Organization: RUNX Un*x Timeshare. Sydney, Australia. Lines: 29 >I'm working in Megamax C, and I noticed a problem while I was in the >debugger. It comes from these statements: > > for (i = ntables; i--; ) > if (i == -1) > >I would expect this to get the value of i, decrement the stored value, >and then exit or execute the statement. Rather, it tests the value >before it decrements, and the loop exits with i = 0. Is this a bug >in the code generation, or is C supposed to do this? > > Greg NEVER confuse the For statement - for(pre-int,test,re-init) Try the following: for (i = ntables;;i--) if (i == -1) < more statements> /* Jason Haines ACSnet: baron@runx * 73 Davidson Avenue CSNET: baron@runx.oz * Concord NSW 2137 ARPA: baron%runx.oz@seismo.css.gov * AUSTRALIA * * UUCP: * {enea,hplabs,mcvax,prlb2,seismo,ubc-vision,ukc}!munnari!runx.oz!baron */