Newsgroups: comp.sys.amiga.programmer
Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sdd.hp.com!decwrl!pa.dec.com!bacchus!mwm
From: mwm@pa.dec.com (Mike (My Watch Has Windows) Meyer)
Subject: Re: Compiler code (was a flame fest)
In-Reply-To: amgreene@athena.mit.edu's message of 18 Apr 91 12:20:54 GMT
Message-ID: <MWM.91Apr18113744@raven.pa.dec.com>
Sender: news@pa.dec.com (News)
Organization: Missionaria Phonibalonica
References: <1991Apr16.001748.26530@uncecs.edu>
	<1991Apr16.183638.12808@cs.cornell.edu>
	<1991Apr17.180342.25312@engin.umich.edu>
	<1991Apr18.122054.13695@athena.mit.edu>
Date: 18 Apr 91 11:37:44
Lines: 27

In article <1991Apr18.122054.13695@athena.mit.edu> amgreene@athena.mit.edu (Andrew Marc Greene) writes:
   Oh, but it *is* useful!  What is the value of the following code
   fragment?

     int n = 4;

     (++n) * (--n);

   If the first operand to * is treated first, the answer is 20.  If the
   second operand to * is treated first, the answer is 12.  

Yup, you can tie the compiler writers hands some, and make things like
that have a meaning. I'd rather not tie the compiler writers hands,
and let them generate the fastest code for their machine. A good
compiler that sees what you wrote would generate no code whatsoever -
after all, you don't change n, and you don't assign the value to
anything.  Even if the value wasn't dead, a good compiler could
generate a simple multiply without changing the value of n, and still
be correct.  A better one would generate no code, and still be
correct.

	<mike
--
Can't buy happiness no matter what you do		Mike Meyer
Can't get to heaven on roller skates			mwm@pa.dec.com
Can't take a taxicab to Timbuktu			decwrl!mwm
Life is hard.
