HP Code Advisor Diagnostics

Reference:
4273 floating-point equality and inequality comparisons may be
inappropriate due to round off common in floating-point computation
Cause:
Since floating point numbers are usually subject to rounding-off errors, comparison between
non-constant floating point values may not always be accurate.
Example:
bool check(float v1, float v2) {
return ( v1 == v2 );
}
Action:
Change your program logic to not depend on such comparisons.
Reference:
4274 comparison of pointer with integer zero
Cause:
A pointer is being compared with an integer zero. Equality comparison with integer zero is
allowed for checking if the pointer is null but other comparisons like >, <, and ≤are not valid.
Example:
int main() {
char* ptr = 0;
if(ptr >= 0)
return 1;
}
Action:
Rewrite the expression to use == or !=.
Reference:
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:
4276 relational operator %sq always evaluates to 'false'
Cause:
64 Diagnostics Details