for(;;) vs. while(1) is a draw

Richard A. O'Keefe ok at goanna.cs.rmit.oz.au
Thu May 31 22:58:57 AEST 1990


In article <5927 at buengc.BU.EDU>, bph at buengc.BU.EDU (Blair P. Houghton) writes:
[ you know what he has been writing ]

I want to apologise to Blair Houghton.
I have been reading all his postings on this topic, and the only
interpretation which suggested itself to me was that he was saying
that a compiler could not truthfully be said to conform to the standard
unless under certain conditions about claims about optimisation which
aren't quite clear to me, it generates _exactly_ the same code for
while(1) and for(;;).

So I understood his postings in the same sense as Doug Gwyn and the rest.
Obviously, I'm misreading him.  I _think_ my difficulty lies in seeing
what counts as optimisation.  For example, if we consider a compiler
which generates assembly code, should the labels generated have exactly
the same spelling?  If the for(;;) code has an extra unused label (it's
easy to imagine a dumb compiler planting a jump around nothing to
handle expr-3 and then the peep-hole optimiser deleting the jump and
leaving the label), does that count as identical code or not?  Please,
this is serious.  I want to know what it is about object code
generated under this or that claim about optimisation which the ANSI
C standard can govern.  I haven't a current copy of the standard, so
it may well say all sorts of things, for all _I_ know to the contrary.

In particular, given the possibility of "compiling" C by stuffing it
through lexical passes alone and executing the token sequence
interpretively, how can _any_ compiler writer truthfully claim to be
doing "no optimisation" in the sense required?  I don't understand this.
Who are the compiler writers who are making this claim?

> Because I don't like compilers that get ahead of my debugging.
Can't disagree with that; on the other hand, when I skip over a
procedure call, I'd rather not wait for it too long.  Just as long
as the compilers don't get too far ahead of _their_ debugging (:-).

-- 
"A 7th class of programs, correct in every way, is believed to exist by a
few computer scientists.  However, no example could be found to include here."



More information about the Comp.std.c mailing list