|
![]() Click on image to see enlargment |
|
PC-lint/FlexeLint Output | Reference Manual Explanation | Home bug438.cpp
An elderly leprechaun, with an uncanny ability to count shamrock leaves, but with waining programming skills, wanted to determine the number of shamrocks in a field. His ancient forebears had determined the average number of leaves per shamrock. But his program seems to be failing him. What's going wrong? bug438.cpp lint Output
--- Module: bug438.cpp (C++)
_
return leaves;
bug438.cpp(12) : Warning 438: Last value assigned to variable 'shamrocks'
(defined at line 8) not used
_
}
bug438.cpp(13) : Warning 550: Symbol 'shamrocks' (line 8) not accessed
Reference Manual Explanation
438 Last value assigned to variable 'Symbol' not used -- A value had
been assigned to a variable that was not subsequently used. The
message is issued either at a return statement or at the end of a
block when the variable goes out of scope. For example, consider
the following function:
void f( int n )
{
int x = 0, y = 1;
if( n > 0 )
{
int z;
z = x + y;
if( n > z ) { x = 3; return; }
z = 12;
}
}
Here we can report that x was assigned a value that had not been
used by the time the return statement had been encountered. We
also report that the most recently assigned value to z is unused
at the point that z goes out of scope. See message 838 in
Section 13.4 C Informational Messages and flags -fiw and -fiz in
Sections 2.3.6 Initialization-is-considered-a-Write flag (-fiw)
and 2.3.7 Initialization-by-Zero-is-considered-a-Write flag
(-fiz).
This message is suppressed if the variable's address is assigned
to a pointer (or, equivalently, the variable is used to directly
initialize a reference to non-const).
If you have comments or questions about this bug, please post them to our Discussion Forum |
Previous Bug - Bug #587 - February 2009