|
![]() Click on image to see enlargment |
|
PC-lint/FlexeLint Output | Reference Manual Explanation | Home bug671.cpp
This program (an abstraction from a larger program) was intended to create an appropriate greeting for the celebration of Independence Day in the United States. But something is going wrong. What is it? bug671.cpp lint Output
--- Module: bug671.cpp (C++)
_
strncat( greeting, names, len );
bug671.cpp(9) : Info 732: Loss of sign (arg. no. 3) (int to unsigned int)
bug671.cpp(9) : Warning 671: Possibly passing to function 'strncat(char *,
const char *, unsigned int)' a negative value (-1), arg. no. 3 [Reference:
file bug671.cpp: line 8]
_
int len = strlen( country );
bug671.cpp(14) : Info 713: Loss of precision (initialization) (unsigned int to int)
Reference Manual Explanation
671 Possibly passing to function 'Symbol' a negative value (Integer),
Context Reference -- An integral value that may possibly be
negative is being passed to a function that is expecting only
positive values for a particular argument. The message contains
the name of the function (Symbol), the questionable value
(Integer) and the argument number (Context). The function may be
a standard library function designed to accept only positive
values such as malloc or memcpy (third argument), or may have
been identified by the user as such through the -function or -sem
options. See message 422 for an example and further explanation..
CommentaryWho's passing a negative value to strncat(), you ask? Well, no one, at least not in this example. But the test that precedes the call to strncat() is shunting away anything but negative values. It's a classic case of one test revealing an error other than the one it was designed to catch. If you have comments or questions about this bug, please post them to our Discussion Forum |
Previous Bug - Bug #669 - June 2007