From owner-freebsd-hackers Mon Feb 1 04:03:12 1999 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id EAA07978 for freebsd-hackers-outgoing; Mon, 1 Feb 1999 04:03:12 -0800 (PST) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from titan.metropolitan.at ([195.212.98.131]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id EAA07973 for ; Mon, 1 Feb 1999 04:03:09 -0800 (PST) (envelope-from mladavac@metropolitan.at) Received: by TITAN with Internet Mail Service (5.0.1458.49) id <1CLHRBVW>; Mon, 1 Feb 1999 13:04:19 +0100 Message-ID: <97A8CA5BF490D211A94F0000F6C2E55D09752B@s-lmh-wi-900.corpnet.at> From: Ladavac Marino To: "'Warner Losh'" , Andrew Kenneth Milton Cc: dcs@newsguy.com, hackers@FreeBSD.ORG Subject: RE: some weird C Date: Mon, 1 Feb 1999 13:00:33 +0100 X-Priority: 3 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.0.1458.49) Content-Type: text/plain Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG -- > -----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