Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 1 Feb 1999 13:00:33 +0100
From:      Ladavac Marino <mladavac@metropolitan.at>
To:        "'Warner Losh'" <imp@village.org>, Andrew Kenneth Milton <akm@zeus.theinternet.com.au>
Cc:        dcs@newsguy.com, hackers@FreeBSD.ORG
Subject:   RE: some weird C 
Message-ID:  <97A8CA5BF490D211A94F0000F6C2E55D09752B@s-lmh-wi-900.corpnet.at>

next in thread | raw e-mail | index | archive | help


--
> -----Original Message-----
> From:	Warner Losh [SMTP:imp@village.org]
> Sent:	Sunday, January 31, 1999 8:46 PM
> To:	Andrew Kenneth Milton
> Cc:	dcs@newsguy.com; hackers@FreeBSD.ORG
> Subject:	Re: some weird C 
> 
> 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.
	[ML]  That is, if there is any *after*.  Completely and utterly
	destroying the machine, or better, electrocuting the programmer
	would have been just as correct actions of the compiler.

	At least, one would get what one deserves for invoking undefined
	behavior :)

	/Marino

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?97A8CA5BF490D211A94F0000F6C2E55D09752B>