|
![]() Click on image to see enlargment |
|
PC-lint/FlexeLint Output | Reference Manual Explanation | Home bug794.cpp
The Easter Bunny is using this program to sort out his Easter baskets; but it turns out he's not much of a programmer. There's a bug. Can you spot it? bug794.cpp lint Output
--- Module: bug794.cpp (C++)
_
PreviousBasket->NextBasket = NewBasket;
bug794.cpp(17) : Info 794: Conceivable use of null pointer 'PreviousBasket' in
left argument to operator '->' [Reference: file bug794.cpp: line 11]
Reference Manual Explanation
794 Conceivable use of null pointer 'Symbol' in [left/right] argument
to operator 'String' Reference -- From information gleaned from
earlier statements it is conceivable that a null pointer (a
pointer whose value is 0) can be used in a context where null
pointers are inappropriate. In the case of binary operators one
of the words 'left' or 'right' is used to designate which operand
is null. Symbol identifies the pointer variable that may be
NULL. This is similar to messages 413 and 613 and differs from
them in that the likelihood is not as great. For example:
int *p = 0;
int i;
for( i = 0; i < n; i++ )
p = &a[i];
*p = 0;
If the body of the for loop is never taken then p remains null.
If you have comments or questions about this bug, please post them to our Discussion Forum |
Previous Bug - Bug #1411 - March 2008