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

PC-Lint (possibly off topic)

298 views
Skip to first unread message

fw

unread,
Oct 1, 1999, 3:00:00 AM10/1/99
to
Using Visual Studio C++ 6.0

Does anyone use PC-Lint from Gimpel software? It seems they do not offer
any
after-sales support. I have submitted (emailed them) simple questions about
possible bugs in their product (version 7.50j) and have gotten absolutely no
response from them. I like the product, but it's ironic that PC-Lint helps
programmers find bugs, and at the same time, they won't even acknowlege
email support question about possible bugs!

The problem - checking a pointer for NULL with if statement.

if ( !ptr )
Info 774: Boolean within 'if' always evaluates to False

if (ptr)
Info 774: Boolean within 'if' always evaluates to True

PC-Lint seems to think these pointers are always non-null. I wish! There
may be a good
reason for this warning; I wish I knew what it was. Is it because a NULL
pointer is not
necessarily zero?

Jim Marshall

unread,
Oct 2, 1999, 3:00:00 AM10/2/99
to
NULL is always 0, from stdio.h

#ifdef __cplusplus
#define NULL 0
#else
#define NULL ((void *)0)
#endif

I can't speak for PC-Lint but personally I find it easier to read if the if
statement is explicit

if (NULL == ptr)

--
Visit: http://ourworld.compuserve.com/homepages/jjmarshall/


Katy Mulvey [MVP]

unread,
Oct 5, 1999, 3:00:00 AM10/5/99
to
In <37f4d8cb$0$2...@nntp1.ba.best.com>, fw

<a...@b.com> wrote:
>Does anyone use PC-Lint from Gimpel software? It seems they do not offer
>any
>after-sales support. I have submitted (emailed them) simple questions about
>possible bugs in their product (version 7.50j)

Download the latest version! They're up to patch level 'r'.

>The problem - checking a pointer for NULL with if statement.
>
> if ( !ptr )
>Info 774: Boolean within 'if' always evaluates to False
>
> if (ptr)
>Info 774: Boolean within 'if' always evaluates to True
>
>PC-Lint seems to think these pointers are always non-null. I wish!

I'd need more context in your code to be able to try and figure out
what they're thinking here. An extremely simple test program doesn't
cause this warning.

- Katy

--
Katy Mulvey Please post replies to the newsgroup, thanks!
ORMEC Systems MVP/VC++
http://www.ormec.com http://support.microsoft.com/support/supportnet/
supportpartners/mvps/brochuregeneral.asp

Owen F. Ransen

unread,
Oct 6, 1999, 3:00:00 AM10/6/99
to
On Fri, 1 Oct 1999 08:51:16 -0700, "fw" <a...@b.com> wrote:

>Using Visual Studio C++ 6.0
>

>Does anyone use PC-Lint from Gimpel software? It seems they do not offer
>any
>after-sales support. I have submitted (emailed them) simple questions about

>possible bugs in their product (version 7.50j) and have gotten absolutely no
>response from them. I like the product, but it's ironic that PC-Lint helps
>programmers find bugs, and at the same time, they won't even acknowlege
>email support question about possible bugs!

A lesson to programmers who want to start their own business,
make a product which has no competitors! I've had the same
problems with them a couple of times, but if you persist
they generally come back sooner or later...


> if ( !ptr )
>Info 774: Boolean within 'if' always evaluates to False

It is probable, if you look at your code carefully, that
you set ptr to NULL or 0 somewhere, and none of the
logic of the program will ever set it to anything else.


> if (ptr)
>Info 774: Boolean within 'if' always evaluates to True

Same here.

As the other posters have said you have not given enough
context....

--------------------------------------------------
http://www.ransen.com the home of Repligator
Winner SIAF awards - Best Graphics Program of 1999

Joseph M. Newcomer

unread,
Oct 6, 1999, 3:00:00 AM10/6/99
to
Well, testing a pointer as being NULL by using the ! operator is a
silly way to do it; it is leftover from the PDP-11 C implementation
where this saved one instruction, and the programmers thought it was
clever. It isn't. It is obscure, hard to read, and I think poor
programming. I always write
if(ptr == NULL)
or
if(ptr != NULL)

which is easy to read, and doesn't give Lint diagnostics.

Harder to write? Anyone who argues from this viewpoint is already in
trouble. Code should be easy to read, and the trivial few keystrokes
required to make it so are worthwhile in the long run.
joe

Joseph M. Newcomer
email: newc...@flounder.com
Web: www3.pgh.net/~newcomer
MVP Tips: www3.pgh.net/~newcomer/mvp_tips.htm
Author of "Win32 Programming" (with Brent Rector, Addison-Wesley, 1997)
Author of "Developing Windows NT Device Drivers" (with Ed Dekker, AWL, 1999)

Dan Maslowski

unread,
Oct 6, 1999, 3:00:00 AM10/6/99
to
Joe,

AMEN! Excellent point and completely accurate.

Dan

Joseph M. Newcomer <newc...@flounder.com> wrote in message
news:Swn7NwFcb2IxU6...@4ax.com...

Owen F. Ransen

unread,
Oct 7, 1999, 3:00:00 AM10/7/99
to
On Wed, 06 Oct 1999 04:35:46 -0400, Joseph M. Newcomer
<newc...@flounder.com> wrote:

>Well, testing a pointer as being NULL by using the ! operator is a

>silly way to do it...
er...I agree.

> if(ptr == NULL)
>or
> if(ptr != NULL)

And
if (NULL == ptr)
which prevents an accidental...
if (NULL = ptr)


>which is easy to read, and doesn't give Lint diagnostics.
>
>Harder to write?

Er....I agree with you.

The point is that the bloke (or blokess) who posted the original
message did not give us enough to go on... And are they ashamed
of themselves, who is "fc" anyway?

PC-LINT almost certainly was not in error here.

0 new messages