Re^2: Can lint help an ANSI-C programmer?
Mike Percy
grimlok at hubcap.clemson.edu
Thu May 31 06:32:38 AEST 1990
cml at tove.cs.umd.edu (Christopher Lott) writes:
>Someone please correct me if some compilers flag these sorts of faults.
>gcc, for one, does not flag test-of-constant conditions, not even when
>told "-Wall -ansi -pedantic"
TurboC seems to do a pretty good job here with -A -wall
It catches:
ANSI Violations
Redefinition of xxx is not identical
Both return and return of a value used
xxx not part od a structure
Undefined structure xxx
Suspicious pointer conversion
Void functions may not return a value
Zero length structure
Common Errors
xxx is assigned a value that is never used
Possible use of xxx before definition
Code has no effect
Parameter xxx is never used
Possibly incorrect assignment /* usually in if(i = 1)...*/
Unreachable code
Function should return a value
Less Common Errors
Ambigous operators need parentheses
Superflous & with function or array
No declaration for function xxx
Call to function with no prototype
Structure passed by value /* assuming you meant &x, not x */
xxx declared but never used
Portability warnings
Non-portable pointer assignment
Constant is long
Non-portable pointer comparison
Constant out of range in comparison
Non-portable return type conversion
Conversion may lose significant digits
Mixing pointers to signed and unsigned char
These are all individually controllable also.
Incidently, I first encountered the warning about 'Conversion may lose
significant digits' dealing with a the [] operators. I had declared p
as int far *p; and done p = (int far *p) farmalloc(100000ul); and
subsequently done something like i = foo(a,b,c); x = p[i]; and got this
warning. The variables i and x were both properly defined. If I
remember right, I had to decalre p as int huge *p; to make this work.
More information about the Comp.lang.c
mailing list