HP Code Advisor Diagnostics Reference Guide (5900-1865, July 2011)
2.81 2826 %n was never referenced
Cause:
This function definition contains a parameter n that was never referenced.
Example: int foo( int i) {
return 0;
}
Action:
Examine your code to determine if this function parameter is needed in this function.
Reference:
2.82 2830 %n has no corresponding operator delete%s (to be called if
an exception is thrown during initialization of an allocated object)
Cause:
For operator new, a corresponding operator delete needs to be provided so that it can be called
for proper destruction in case an exception is thrown during the initialization of the allocated
object.
Example:
void* operator new(unsigned long, void*) { return 0; }
struct Pool {
Pool() { }
} object;
Pool* allocate() { return new (&object) Pool(); }
Action:
Provide a corresponding operator delete to be called if an exception is thrown during the
initialization of the allocated object.
Reference:
2.83 2836 returning reference to local variable
Cause:
It is incorrect to return a reference to a local variable as the return value from a function. This is
because the lifetime of a local variable ends once the function returns.
Example:
int& foo() {
int i = 10;
return i;
}
Action:
Do not return reference to a local variable; if you really want to return a reference, make the local
variable static. This is because the lifetime of a static variable is same as lifetime of the program.
Reference:
2.84 2837 omission of explicit type is nonstandard ("int" assumed)
Cause:
A declaration or a definition does not have an explicit type, int will be assumed as the type but
this behavior is non-standard.
Example:
2.81 2826 %n was never referenced 47