Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!emory!hubcap!grimlok From: grimlok@hubcap.clemson.edu (Mike Percy) Newsgroups: comp.lang.c Subject: Re^2: Can lint help an ANSI-C programmer? Message-ID: <9171@hubcap.clemson.edu> Date: 30 May 90 20:32:38 GMT References: <6328.265D8157@puddle.fidonet.org> <1754@tkou02.enet.dec.com> <00937758.16FBE220@rigel.efd.lth.se> <24660@mimsy.umd.edu> Organization: Clemson University, Clemson, SC Lines: 47 cml@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.