Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

lint for ANSI C and C++

346 views
Skip to first unread message

Daniel Sears

unread,
Jan 4, 1994, 4:38:30 PM1/4/94
to
Gimpel Software recently released version 6 of their lint software.
This new version includes support for C++ in addition to the support
for ANSI C that has been available for some time.

Gimpel Software
3207 Hogarth Lane
Collegeville, PA 19426
Phone: (215) 584-4261
FAX: (215) 584-4266
BBS: (215) 584-4510
CompuServe: 73737,3064

I've appended the product literature for both their C and C/C++ versions to
this message. Of course, I have no personal connection to Gimpel Software.

--Dan

===============================
lintpp.txt
===============================
GIMPEL SOFTWARE
3207 Hogarth Lane
Collegeville, PA 19426
Phone (215)584-4261
FAX (215)584-4266


Introducing PC-lint for C/C++


"C++ is one of the most grotesque and cryptic programming languages ever created"

Ray Duncan

Yes, as Ray Duncan has stated, C++ is grotesque and cryptic and anyone
swimming in these strange and unfamiliar waters is best advised to get
all the help they can get. And what better source of help than a
friendly, knowledgeable lint? But, as the C++ pioneers discovered, just
when they needed it the most, their favorite lint tool deserted them
because it couldn't process the extended syntax for C++. Since we're in
the lint business, we were deeply embarrassed by these events and so our
first task was to enhance PC-lint so that it could parse C++.

Viewed initially as a six-month effort, it turned into a two year
project. We had to handle not only all the linguistic subtleties that
our customer base was likely to program directly, but all the library
header files they were likely to use. These generally are written by
C++ experts employing every language nuance.

Therefore our primary focus in this release is to completely parse all
of C++, without compromise, while still retaining all the old and
familiar lint checks. These include uninitialized variables, unused
functions, strong type checking, signed-unsigned irregularities, etc.
etc. We added to our repertoire of checks many of those suggested by
the C++ experts such as Scott Meyers, Tom Cargill and Andy Koeing. In
fact, the C++ effort was so large that we had to worry about the size of
the "error number space". Accordingly numbers 1000-1999 have been
dedicated to C++ messages and have been partitioned into Error, Warning,
Informational and Elective Note messages in a manner reflective of the
partitioning of the lower 0-999 space. We currently include over 130
new messages in the C++ category. A partial listing of the checks
appears below.

Our C++ product supports a mixed suite of C and C++ modules (much as the
compilers do) with all the appropriate cross-module checks to ensure,
for example, that extern's in C modules are extern "C" to the C++
modules. It is important to create a single tool to be employed for
both C and C++. Our C++ product processes C modules as quickly and
yields the same diagnostics as our C-only product. There's only one
hitch. Our C++ offering does not (yet) support Lint Object Modules. It
is primarily for this reason that we offer two different versions:
PC-lint for C and PC-lint for C++.

Should the C-only programmer update at this time? There have been a
number of bug fixes and general improvements that will help C-only
programmers, including one-line message suppression (see the list
below). If you need and want these features please update. But bear in
mind, we have designed this release for the C++ programmer.


New C++ Messages

o C++ Warning Messages
- Defined object has no data members.
- A tagged union is not anonymous.
- No access specifier provided.
- Call to virtual function within a constructor or
destructor.
- Attempting to 'delete' an array.
- Base class destructor for class is not virtual.
- Base class has no destructor.
- Member hides non-virtual member.
- Destructor for base class is not virtual.
- Storage class ignored.
- Multiple copy constructors for class.
- new in constructor for class which has no
assignment operator.
- new in constructor for class which has no copy
constructor.
- Member function not defined.
- Static member not defined.

o C++ Informational Messages

- Redundant access-specifier.
- Operator is both an ordinary function and a
member function.
- Static class member may be accessed by the
scoping operator.
- Declaration with scope operator is unusual within
a class.
- static assumed.
- Class has a virtual function but is not inherited.
- Default constructor not defined for class.
- Redundant parentheses ignored.
- Member function not referenced.
- Static member not referenced.
- Empty prototype for function declaration,
assumed '(void)'.
- Expression within brackets ignored.
- Assignment operator for class has
non-reference parameter.
- Assignment operator for class has non-const
parameter.
- operator =() for class is not assignment
operator.
- Assignment operator for class does not return
a reference to class.
- Argument to copy constructor should be a
const reference.
- Class member is a reference.
- Taking address of overloaded function name.
- Inline function not previously defined inline.
- Initializer inversion detected for member.
- Local template not referenced.
- Global template not referenced.

o C++ Elective Notes

- Creating a temporary of type 'Type'.
- Useless ';' follows '}' in function definition.
- Old-style C comment.
- 'virtual' assumed.
- Implicit constructor call.
- Implicit call of conversion function.
- Empty prototype for definition, assumed '(void)'.
- Empty prototype for member declaration,
assumed (void).
- Multiple assignment operators for class Symbol.
- Casting to a reference.


PC-lint 6.00 New Features

o One-line message suppression (!e#).
o "-esym" accepts wild-card characters.
o An environment variable within a pair of '%' characters may be placed on the command
line or within a .lnt file.
o Full support for #line.
o Support for the High C and Unix conditional include preprocessor directives.
o The header not-used message has been strengthened so that when headers include other
headers the entire group is considered as one.
o The Warning Level (-w) now affects only those messages in the 'delta', from some
prior Level to some new Level.

o New Size Options
-smp# size of Member Pointers becomes #.
-smpD# size of member Data pointers is # bytes.
-smpP# size of member Program pointers is # bytes.
-smpFP# size of a member far Program pointer.
-smpNP# size of a member near Program pointer.
-sw# size of wchar_t becomes #.

o New Error Inhibition Options
-epuc Ignore pointer to unsigned char vs pointer to char differences in assignment.
-epnc Ignore pointer to nominal char differences in assignment.

o New Flag Options
fcp process modules as C++
fdc Distinguish-plain-Char
feb allow Enumerations as Bit fields
fem allow Early Modifiers (High C style)
fim Include-Multiple directories as in -idir;dir
flf process Library-Function definitions
fln #LiNe directives are followed for the purpose of message reporting
fnt Nested Tags enabled. Special searches are initiated for invisible tags with
suitable commentary.
fwc wchar_t is built-in
fwu wchar_t is Unsigned

o New Message Height Options
mn requests No Macro display
m restore the macro display
m/M/ restore the macro display and use user-defined prefix M

o Other New Options
+cpp(extension)recognize extension as another C++ file extension.
-header(filename) force PC-lint to read the header
filename at the outset of each module.
-limit(n) impose an upper limit (n) on the number of messages that will be
produced.
-default_ext(extension) change the default extension
===============================
lint.txt
===============================
GIMPEL SOFTWARE
3207 Hogarth Lane
Collegeville, PA 19426
Phone (215) 584-4261
FAX (215 )584-4266


C is both powerful and efficient. But this power, if not used properly,
can be the source of obscure bugs and unreliable software. PC-lint will
look across your multiple modules and find bugs, glitches and
inconsistencies. It will make your program more reliable, more
maintainable and more portable. For example:

1: void main()
2: {
3: struct {unsigned a:1, b:3, c:4; } s;
4: unsigned row, col, z;
5: char ch, y;
6: int x = 0;
7:
8: row = 26; col = 80; if( row + col > -1 ) x++;
9: ch = '\xFF'; if( (unsigned) ch == 0xFF ) x++;
10: z = 2; y = (z & 0x3) << 7; if( y ) x++;
11: z = 12; if( z / -1 ) x++;
12: s.b = 10; if( s.b > 5 ) x++;
13: z = 37; if( -z < 0 ) x++;
14: }

After x is initialized to 0 in the program above, it is possibly
incremented at each "if" statement. Each "if" clause looks as though it
should be true. For most compilers, however, each is false and x results
in a value of 0 or close to it. Yet few compilers warn you of the unusual
constructs. Here is the output from PC-lint:


--- Module: quiz.c
_
row = 26; col = 80; if( row + col > -1 ) x++;
quiz.c 8 Warning 650: Constant out of range for operator '>'
quiz.c 8 Warning 574: Signed-unsigned mix with relational
quiz.c 8 Info 737: Loss of sign in promotion from int to unsigned int
_
ch = '\xFF'; if( (unsigned) ch == 0xFF ) x++;
quiz.c 9 Info 743: Negative character constant
quiz.c 9 Warning 571: Suspicious cast
_
z = 2; y = (z & 0x3) << 7; if( y ) x++;
quiz.c 10 Info 734: Loss of precision (assignment) (9 bits to 7 bits)
_
z = 12; if( z / -1 ) x++;
quiz.c 11 Warning 573: Signed-unsigned mix with divide
quiz.c 11 Info 737: Loss of sign in promotion from int to unsigned int
_
s.b = 10; if( s.b > 5 ) x++;
quiz.c 12 Warning 542: Excessive size for bit field
_
z = 37; if( -z < 0 ) x++;
quiz.c 13 Warning 501: Expected signed type
quiz.c 13 Warning 568: unsigned is never less than zero
_
}
quiz.c 14 Warning 550: x (line 6) not accessed

--- Wrap-up for Module: quiz.c

Info 754: local structure member a (line 3, file quiz.c) not referenced
Info 754: local structure member c (line 3, file quiz.c) not referenced

PC-lint Representative Checks

PC-lint will find many more bugs than can be exhibited in a simple
example. It includes the following kinds of checks:

- Intermodule type inconsistencies
- Function parameter mismatches in number or in type, even across multiple
modules.
- Value return inconsistencies for functions (information is gleaned from
return statements, calls, and optionally, declarations).
- Used but not initialized errors (for auto, static and global variables,
arrays and structs).
- Declared but not used.
- Used but not defined.
- Assigned but not accessed (for auto, static and global variables, arrays
and structs).
- Unreachable code.
- Unusual uses of Booleans as in: flags & 4 == 0 (the programmer thought
that & had a higher precedence that ==, it does not).
- Constant Booleans as in: if( x = 0 )... (this ex-Pascal programmer
thought he was testing for x being 0).
- Indentation checking.
- Pre-processing anomalies
- Suspicious uses of semi-colons as in: if(a>b); not followed by 'else'
(legal C but highly suspect)
- Strict and loose enumeration checking.
- printf - scanf format checking.
- Order of evaluation errors, as in a[i] = i++;
- unsigned comparisons with 0.
- Wide variety of loss of precision errors such as "int" to "char"
featuring our exclusive precision tracking.
- Excessive shift values.
- Loss of sign.
- Suspicious cast
- Mixing signed and unsigned quantities.
- Comments within comments.
- Pointer irregularities such as increase in pointer capability and
returning pointers to auto.
- ANSI 'Quiet Changes'
- Unusual compile-time objects, including macros, typedef's, declarations,
struct's, union's, enum's.
- Header files not used.
- Externals that can be made static.
- Declarations that can be offloaded from headers.
- Name clashes within first count characters.
- One declaration hiding another.

New Checks in Version 5.0

- Strong type checking based on typedef types.
- Possibly uninitialized variables based on flow of control.
- Overflow while processing arithmetic constants. (200 * 200)
- Constant expressions that reduce to zero. (AFLAG & BFLAG)
- Suspicious truncations. (long = int * int)
- Recognizes exit, free, realloc, longjmp, abort, setjmp. Transfer
properties to user functions.
- Initializer irregularities.

Other Features

- Supports both K&R and ANSI C.
- One pass so it's very fast.
- Uses all the storage available. Internal tables are not fixed in size
but will expand dynamically.
- Automatic generation of prototypes/declarations.
- Wild card expansion.
- Auto Help information.
- Five kinds of error messages: Fatal, Syntactic, Warning, Informational,
and Elective Notes.
- Wide range of error inhibition options. Inhibit errors by error number,
by "wild-card" methods, by symbol name, by file name or by type
difference.
- Supports an indirect file that may contain command line options and file
names.
- For porting programs to other machines, you may optionally set the size
of all scalars for the target machine.
- Optional preprocessor output -- Run PC-lint just as a preprocessor for
diagnostic purposes or as a tool.
- Supports include-file directories.
- Fully parameterized messages.
- All command line options may be placed within a C program by means of a
special lint-detected comment.
- Format of error messages can be customized.
- User-modifiable compiler options files.
- Incremental linting using lint object modules.

*** C++ support is available with PC-lint for C/C++ Version 6

PC-lint is a trademark of Gimpel Software

GIMPEL SOFTWARE
3207 Hogarth Lane
Collegeville, PA 19426
Phone (215) 584-4261
FAX (215) 584-4266
______________________________

PC-lint runs on MS-DOS (includes a 386-DOS extended executable) and OS/2

PC-lint for C is $139.

PC-lint for C/C++ is $239.
--

E-mail: se...@netcom.com
Phone: 415.695.0650
Address: 2440 16th Street #283
San Francisco, CA 94103-4211

0 new messages