Click on image to see enlargment
Archie, a fantasy baseball enthusiast, is preparing to do a computer analysis of all of last year's score cards. This program is intended to find the total number of strikeouts ("K"s) recorded. But something's going wrong.
bug413.cpp lint Output
--- Module: bug413.cpp (C++) _ for( p = buf; *p; p++ ) bug413.cpp(12) : Warning 413: Likely use of null pointer 'p' in argument to operator 'unary *' [Reference: file bug413.cpp: lines 10, 12] _ if( *p == ch ) total++; bug413.cpp(13) : Warning 613: Possible use of null pointer 'p' in argument to operator 'unary *' [Reference: file bug413.cpp: lines 10, 12] bug413.cpp(12) : Warning 613: Possible use of null pointer 'p' in argument to operator '++' [Reference: file bug413.cpp: lines 10, 12] _ if( (s = score_cards[i]) ) bug413.cpp(22) : Info 820: Boolean test of a parenthesized assignment
Reference Manual Explanation
413 Likely use of null pointer 'Symbol' in [left/right] argument to operator 'String' Reference -- From information gleaned from earlier statements, it appears certain that a null pointer (a pointer whose value is 0) has been used in a context where null pointers are inappropriate. These include: Unary *, pointer increment (++) or decrement(--), addition of pointer to numeric, and subtraction of two pointers. 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.
Previous Bug - Bug #415 - March 2012