From owner-freebsd-hackers Sun Jan 31 12:03:48 1999 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id MAA13357 for freebsd-hackers-outgoing; Sun, 31 Jan 1999 12:03:48 -0800 (PST) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from rover.village.org (rover.village.org [204.144.255.49]) by hub.freebsd.org (8.8.8/8.8.8) with SMTP id MAA13346 for ; Sun, 31 Jan 1999 12:03:46 -0800 (PST) (envelope-from imp@village.org) Received: from harmony [10.0.0.6] by rover.village.org with esmtp (Exim 1.71 #1) id 1072og-0000VB-00; Sun, 31 Jan 1999 12:45:58 -0700 Received: from harmony.village.org (localhost.village.org [127.0.0.1]) by harmony.village.org (8.9.1/8.8.3) with ESMTP id MAA90385; Sun, 31 Jan 1999 12:46:29 -0700 (MST) Message-Id: <199901311946.MAA90385@harmony.village.org> To: Andrew Kenneth Milton Subject: Re: some weird C Cc: dcs@newsguy.com (Daniel C. Sobral), hackers@FreeBSD.ORG In-reply-to: Your message of "Sun, 31 Jan 1999 20:35:55 +1000." <199901311035.UAA28754@zeus.theinternet.com.au> References: <199901311035.UAA28754@zeus.theinternet.com.au> Date: Sun, 31 Jan 1999 12:46:29 -0700 From: Warner Losh Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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