Article View: comp.std.c
Article #1290Re: for(;;) vs. while(1) is a draw
From: P E Smee
Date: Fri, 25 May 1990 09:21
Date: Fri, 25 May 1990 09:21
24 lines
1706 bytes
1706 bytes
In article <12971@smoke.BRL.MIL> gwyn@smoke.BRL.MIL (Doug Gwyn) writes: >If a compiler is going >to generate a useless comparison, it is in fact more likely >to do so for while(1) than for for(;;). One benefit of 'for(;;)' over 'while (1)' which I haven't seen mentioned is that most (in my experience) versions of 'lint' will cheerfully accept 'for(;;)' without comment, while giving a 'constant in conditional' warning for 'while(1)'. You could plausibly argue that lint is broken and should recognize this use of while as a special case. You could also plausibly argue that C should have an explicit 'do forever' construct. However, neither of these seem to be true, and I have no control over them; I can control my code and like it to be lint-free (or as near as possible -- 'There are some things you just cant get lint to shut up about' from lint(1)). (Yeah, I know how to hide things from lint. I don't like to do that, though, for fear that I'll make a REAL error which it would have caught, somewhere where it can't see it because I've hidden it.) -- Paul Smee, Computing Service, University of Bristol, Bristol BS8 1UD, UK P.Smee@bristol.ac.uk - ..!uunet!ukc!bsmail!p.smee - Tel +44 272 303132
Technical Details
Message-ID:
<1990May25.092150.24611@gdr.bath.ac.uk>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!uunet!mcsun!ukc!dcl-cs!gdt!exspesReferences:
<5876@buengc.BU.EDU> <12955@smoke.BRL.MIL> <5879@buengc.BU.EDU> <12971@smoke.BRL.MIL>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!uunet!mcsun!ukc!dcl-cs!gdt!exspes From: exspes@gdr.bath.ac.uk (P E Smee) Newsgroups: comp.std.c Subject: Re: for(;;) vs. while(1) is a draw Message-ID: <1990May25.092150.24611@gdr.bath.ac.uk> Date: 25 May 90 09:21:50 GMT References: <5876@buengc.BU.EDU> <12955@smoke.BRL.MIL> <5879@buengc.BU.EDU> <12971@smoke.BRL.MIL> Organization: University of Bristol c/o University of Bath Lines: 24