Click on image to see enlargment
The programmer found an interesting way to map one string to another but there are potential trouble spots. Can you spot them?
bug613.cpp lint Output
--- Module: bug613.cpp _ cSTR find = strstr( x, op ) + strlen(op); bug613.cpp(8) : Warning 613: Possible use of null pointer 'unknown-name' in left argument to operator 'ptr+int' [Reference: file bug613.cpp: line 8] _ strncpy( buf, p1, len ); bug613.cpp(17) : Info 732: Loss of sign (arg. no. 3) (int to unsigned int) During Specific Walk: File bug613.cpp line 9: sub_string(!=0, 0?) bug613.cpp(15) : Warning 613: Possible use of null pointer 'p2' in left argument to operator 'ptr-ptr' [Reference: file bug613.cpp: line 9]
Reference Manual Explanation
613 Possible use of null pointer 'Symbol' in [left/right] argument to operator 'String' Reference -- From information gleaned from earlier statements, it is possible that a null pointer (a pointer whose value is 0) can be used in a context where null pointers are inappropriate. Such contexts 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. See also messages 413 and 794.
If you have comments or questions about this bug, please post them to our Discussion Forum
Previous Bug - Bug #579 - June 2004