Article View: comp.std.c
Article #1301Re: for(;;) vs. while(1) is a draw
From: Guy Harris
Date: Sat, 26 May 1990 18:31
Date: Sat, 26 May 1990 18:31
40 lines
2123 bytes
2123 bytes
>Ayup. They'd be optimizing without being asked to, So what? > for(;;) statement > > while(1) statement > > label: statement if(1) goto label; > >are all the same; exactly the same, when translated into object code >without thinking about it. You could contend that the third is >my invention, but the standard says the first two are identical. The standard does *NOT* say, in any way, shape, or form, that they are "exactly the same, when translated into object code without thinking about it". (The standard doesn't even say that an implementation necessarily translates them into object code!) It just says that they have to *act* the same. How the compiler arranges that that happen is *not* X3.159-1989's business. >I didn't say the standard specified optimization. Well, if you didn't say anything about what the standard said, why are you saying it *here*? As several people have noted, the standard does not dictate, *one way or the other*, whether "for(;;)" and "while(1)" have to generate the exact same object code; all it says is that the object code generated, assuming object code is generated at all, has to provide the same semantics for both constructs. >I said the implementor did, or rather, the implementor specified a _lack_ >of it. Then it went and optimized. "Optimization" is in the eye of the beholder. Perhaps that's why the standard doesn't tend to talk about it? *I* don't demand that a compiler, when no "optimization" is specified, generate code by the most naive algorithm possible, i.e. "without thinking about it". If you do, that's your choice. For better or worse, plenty of other people, I suspect, don't demand it either.
Technical Details
Message-ID:
<3398@auspex.auspex.com>Path:
arc1-ca.pugleaf.net!utzoo!attcan!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!auspex!guyReferences:
<5879@buengc.BU.EDU> <3381@auspex.auspex.com> <5905@buengc.BU.EDU>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!auspex!guy From: guy@auspex.auspex.com (Guy Harris) Newsgroups: comp.std.c Subject: Re: for(;;) vs. while(1) is a draw Message-ID: <3398@auspex.auspex.com> Date: 26 May 90 18:31:32 GMT References: <5879@buengc.BU.EDU> <3381@auspex.auspex.com> <5905@buengc.BU.EDU> Organization: Auspex Systems, Santa Clara Lines: 40