|
![]() Click on image to see enlargment |
|
PC-lint/FlexeLint Output | Reference Manual Explanation | Home bug1416.cpp
In an effort to understand references, a student wrote this program that is chock full of references, even class members. But his program is producing inconsistent results with different compilers. Can you spot the problem? bug1416.cpp lint Output
--- Module: bug1416.cpp (C++)
_
double &x, &y;
bug1416.cpp(7) : Info 1725: class member 'Complex::x' is a reference
bug1416.cpp(7) : Info 1725: class member 'Complex::y' is a reference
_
Complex( double &z ) : x(y), y(z) { }
bug1416.cpp(9) : Warning 1416: An uninitialized reference 'Complex::y' is being
used to initialize reference 'Complex::x'
_
{ return sqrt( square(c.x)+square(c.y) ); }
bug1416.cpp(15) : Info 1764: Reference parameter 'c' (line 14) could be
declared const ref
Reference Manual Explanation
1416 An uninitialized reference 'Symbol' is being used to initialize
reference 'Symbol' -- This message is usually issued when a
reference to a member of a class is used to initialize a
reference to another member of the same class before the first
member was initialized. For example:
class C
{
int &n, &m;
C( int &k ) : n(m), m(k) { /* ... */ }
};
If you have comments or questions about this bug, please post them to our Discussion Forum |
Previous Bug - Bug #583 - December 2008