lint won't verify printf formatting against variable types??

Scott Horne Horne-Scott at cs.yale.edu
Fri Jun 30 03:44:54 AEST 1989


In article <27729 at lll-winken.LLNL.GOV>, berry at lll-crg (Berry Kercheval) writes:
> In article <441a30e5.8f55 at fiero.engin.umich.edu>, ejd at 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 at 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?



More information about the Comp.lang.c mailing list