Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!yale!Horne-Scott From: Horne-Scott@cs.yale.edu (Scott Horne) Newsgroups: comp.lang.c Subject: Re: lint won't verify printf formatting against variable types?? Keywords: lint, cc Message-ID: <65088@yale-celray.yale.UUCP> Date: 29 Jun 89 17:44:54 GMT References: <328@tree.UUCP> <417@siswat.UUCP> <441a30e5.8f55@fiero.engin.umich.edu> <27729@lll-winken.LLNL.GOV> Sender: root@yale.UUCP Reply-To: Horne-Scott@cs.yale.edu (Scott Horne) Organization: Yale University Computer Science Dept, New Haven, CT 06520-2158 Lines: 34 In-reply-to: berry@lll-crg.llnl.gov (Berry Kercheval) In article <27729@lll-winken.LLNL.GOV>, berry@lll-crg (Berry Kercheval) writes: > In article <441a30e5.8f55@fiero.engin.umich.edu>, ejd@caen (Edward J Driscoll) writes: > >It [[ if(x==5); ]]is legal, but I would hope for a warning from such an > > obvious semantic error. > > Goodness, save me from useless warnings for perfectly good C > constructs. This is NOT an "obvious" semantic error. Have you never > done something like this? > > /* skip to end of word */ > while(!isspace(*cp++)); You're missing the point. `if(x == 5);' is not necessarily a semantic error, but it probably is. `while' constructs with null bodies are useful, but `if' constructs like the one above are not. Consider what `if(x == 5);' does: *nothing*! If x == 5, the program continues; if x != 5, the program continues the same way. There aren't even any side effects; but even if there were, they would be obtained just the same with out the `if'. I'm sure you'll have a hard time thinking of an occasion in which a reasonable programmer would write `if(x == 5);' intentionally. However, I would of course *allow* such constructs, and I think that the compiler should give at most a warning. Such things are best left to programs like `lint'. --Scott Scott Horne Hacker-in-Chief, Yale CS Dept Facility horne@cs.Yale.edu ...!{harvard,cmcl2,decvax}!yale!horne Home: 203 789-0877 SnailMail: Box 7196 Yale Station, New Haven, CT 06520 Work: 203 432-6428 Summer residence: 175 Dwight St, New Haven, CT Dare I speak for the amorphous gallimaufry of intellectual thought called Yale?