|
PC-lint/FlexeLint Output | Reference Manual Explanation | Home Page bug684.cpp
Our programmer wrote a sort function to sort an array without modifying the original. But something's wrong. The first element is right but not the other 9. What's going on? bug684.cpp lint Output
--- Module: bug684.cpp
_
*p = b;
bug684.cpp(12) : Warning 684: Passing address of auto variable 'b' into caller
space
Reference Manual Explanation
684 Passing address of auto variable 'Symbol' into caller
space -- The address of an auto variable was passed via
assignment into a location specified by the caller to the
function. For example:
void f( int *a[] )
{
int n;
a[1] = &n;
}
Here the address of an auto variable (n) is being passed
into the second element of the array passed to the
function f. This looks suspicious because upon return the
array will contain a pointer to a variable whose lifetime
is over. It is possible that this is benign since it
could be that the caller to f() is merely passing in a
working space to be discarded upon return. If this is the
case, you can suppress the message for function f() using
the option
-efunc(684,f)
See also Warning 604.
If you have comments or questions about this bug, please post them to our Discussion Forum |
Previous Bug - Bug #682 - June 2002