Date: Sun, 31 Jan 1999 12:46:29 -0700 From: Warner Losh <imp@village.org> To: Andrew Kenneth Milton <akm@zeus.theinternet.com.au> Cc: dcs@newsguy.com (Daniel C. Sobral), hackers@FreeBSD.ORG Subject: Re: some weird C Message-ID: <199901311946.MAA90385@harmony.village.org> In-Reply-To: Your message of "Sun, 31 Jan 1999 20:35:55 %2B1000." <199901311035.UAA28754@zeus.theinternet.com.au> References: <199901311035.UAA28754@zeus.theinternet.com.au>
next in thread | previous in thread | raw e-mail | index | archive | help
In message <199901311035.UAA28754@zeus.theinternet.com.au> Andrew Kenneth Milton writes: : +----[ Daniel C. Sobral ]--------------------------------------------- : | Andrew Kenneth Milton wrote: : | > : | > +----[ Malartre ]--------------------------------------------- : | > | : | > | I was expecting 9, not 10. : | > | since 4+5=9? : | > : | > x is pre-incremented, making it 5 *before* the += takes effect. : | > : | > This is correct behaviour. : | : | Explain the 8 then... if x++ takes effect *after* +=, it should have : | been 9, right? : : No. the time at which a post increment operation takes place is : undefined, but, before the next *expression* x += x++; is undefined. That's the explaination. If x is 4 before, then it could be 8, 9, 10 or 1045 after the expression, and they would all be right. Waarner To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199901311946.MAA90385>