Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!uunet!seismo!mcnc!ece-csc!ncrcae!ncr-sd!hp-sdd!hplabs!ucbvax!ucdavis!uop!exodus
From: exodus@uop.UUCP (Freddy Kreuger)
Newsgroups: comp.lang.c
Subject: Re: Style [++i vs i++]
Message-ID: <404@uop.UUCP>
Date: Sun, 12-Jul-87 02:41:55 EDT
Article-I.D.: uop.404
Posted: Sun Jul 12 02:41:55 1987
Date-Received: Mon, 13-Jul-87 00:46:42 EDT
References: <17310@amdcad.AMD.COM> <2159@emory.uucp> <43@ghsvax.UUCP> <795@nu3b2.UUCP>
Organization: Somewhere perpendicular to reality...
Lines: 56
Summary: Well...my compiler does this....

> In article <43@ghsvax.UUCP> edk@ghsvax.UUCP (Ed Kaulakis) writes:
>
>Many compilers will materialize the (returned old value) of i++ even 
>when nobody wants it, but will do better with ++i.
Who's C compiler are you using?  Tiny-C?

Well, this is sort-of machine specific (although there are a lot of
680xx boxes out there) but here goes:
The following C code:

	main()
	{
	  int i,j;
	  i=0;
	  i++;
	  ++i;
	  j=i++;
	  j=++i;
	}

Produces:
(Only the '<='s were added by me...)

	/	module name inc_test
		.shri
		.globl main_
	main_:
		link	a6, $-4		<= int i,j;
		clr	-2(a6)		<= i=0
		addq	$1, -2(a6)	<= i++
		addq	$1, -2(a6)	<= ++i
		move	-2(a6), d0	<= j=i++
		addq	$1, -2(a6)	<= ""
		move	d0, -4(a6)	<= ""
		addq	$1, -2(a6)	<= j=++i
		move	-2(a6), d0	<= ""
		move	d0, -4(a6)	<= ""
		unlk	a6		<= Clean up stack
		rts			<= ...and go home!

So my compiler, at least, is semi-intelligent.  And I would expect all
modern C compilers to be.  Or is that too much to ask?  Compilers and
compiler theory has come a long way since the original C, fortran, cobol,
whatever compilers.  There are BASIC (forgive me!) compilers out there
nowadays that produce code as clean as a few C compilers...  No flames
please, I'm just going by published benchmarks.  So what's all the fuss
about, anyways?  Are we all fighting over who's C compiler is better?
When I buy something that I will depend on to make me money, I want it
to work and I want it to work well.  As with any tool, it should meet
the specifications of the buyer before it should be used.  Artists don't
do detailed work with axes... 

Greg Onufer

PS. Code above generated with Mark Williams C ver 2.00 on an Atari ST,
1 Meg Ram, 8 Mhz 68000.