HP Code Advisor Diagnostics Reference Guide (5900-1865, July 2011)

char* ptr = 0;
if(ptr >= 0)
return 1;
}
Action:
Rewrite the expression to use == or !=.
Reference:
2.127 4275 constant out of range (%s) for the operator
Cause:
For a given relational operation the constant is out of range specified by the other non-constant
operand.
Example:
void foo(bool b, char c) {
if (b == 3) { } // warning 4275 here
if (c < 200) { } // warning 4275 here
if ((unsigned char)c < 200) { } // no warning here
}
Action:
Check the value of the constant being used in the operation. In the scenarios where the comparison
is between signed and unsigned types the problem can be fixed by using a cast.
Reference:
2.128 4276 relational operator %sq always evaluates to 'false'
Cause:
The greater than or less than relational operation in the expression always evaluates to false. This
happens when comparing against the largest and smallest values in the range of given type.
Example:
void foo(unsigned char c) {
if (c > 255) {} // warning 4276 here
}
NOTE: 255 is the largest value for an unsigned char so a >
comparison will always be false.
Action:
Check the value of the constant being used in the operation.
Reference:
2.129 4277 logical AND with a constant, do you mean to use '&'?
Cause:
Using a constant in a logical AND (&&) operation is rather unusual. This usually indicates a typo
where the programmer actually meant to say bitwise AND (&). This warning is not generated for
the constant 0 since that often results from macro expansions.
Example: result = value && 0x1; // warning 4277 here
Action:
Check if you meant to use '&' instead of '&&'. For certain macro expansions this can be valid
code, suppress this warning for those macros using the +Wmacro option.
Reference:
2.127 4275 constant out of range (%s) for the operator 61