|
PC-lint/FlexeLint Output | Reference Manual Explanation | Home Page bug1747.cpp
Shown above is just a portion of a larger program. The programmer's lament is that he keeps running out of storage when summing up large arrays of complex numbers. What's his problem?
bug1747.cpp lint Output
Module: bug1747.cpp
_
{
bug1747.cpp 9 Info 1747: binary operator 'operator+(Complex &, Complex &)'
returning a reference
_
return *p;
bug1747.cpp 13 Warning 429: Custodial pointer 'p' (line 10) has not been
freed or returned
--- Global Wrap-up
Info 1754: Expected symbol 'operator+=' to be declared for class 'Complex'
Reference Manual Explanation
1747 binary operator 'Symbol' returning a reference -- An
operator-like function was found to be returning a reference.
For example:
X &operator+ ( X &, X & );
This is almost always a bad idea. [12, Item 23]. You normally
can't return a reference unless you allocate the object, but then
who is going to delete it. The usual way this is declared is:
X operator+ ( X &, X & );
|
Previous Bug - Bug #602 - February 2001