lclint-interest message 123

From Tue Nov 26 15:23:22 1996
Date: Tue, 26 Nov 1996 11:14:45 -0800 (PST)
From: "Albert L. Ting" 
Subject: Re: lclint format-type question
References: <>

David Evans writes:
> From: (David Evans)
> To:
> Subject: lclint format-type question
> Date: Tue, 26 Nov 96 10:52:18 -0500
> Type checking for printf format codes is enabled in -weak mode, the
> difference is the type checking --- since char and int are equivalent in
> weak mode, lclint will not report an error when a char is printed using
> %d, etc.  It will, for instance, report and error when a float is
> printed as %d.  
> If this is what you have in mind, then you would need to set -charint to
> get the errors reported in printf's (as elsewhere).  If there is some
> other kind of error you expect but aren't getting, let me know.
> --- Dave

Below is an example that finds the error in strict mode, but not in weak
mode.  I guess -charint treats char and ints as equivalent, but not shorts?



int main() {
  char *s = "DATA 1 2";
  short num1, num2;

  (void) sscanf(s, "DATA %d %d", &num1, &num2);

Albert L. M. Ting * * phone:408-487-5327 * fax:408-453-3500
VLSI Libraries Incorporated, 2077 Gateway Place, Suite 300, San Jose, CA 95110

Previous Message Next Message Archive Summary LCLint Home Page David Evans
University of Virginia, Computer Science