HP Code Advisor Diagnostics

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:
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:
4278 the sub expression in logical expression is a constant
Cause:
Logical operators follow short-circuit evaluation - if the first operand of a logical || or && operator
determines the result of the expression, the second operand will not be evaluated. In the given
expression the first sub expression is a constant that determines the result of the expression and
hence the rest of the expression will never be evaluated.
Example:
int main() {
int a = 10;
if( 10 || (a == 10))
return 0;
}
Action:
Check if the constant is expected. In some cases the constant value might be the result of a valid
macro expansion, in such scenarios you can suppress this warning for the particular macro using
the +Wmacro option.
Reference:
4279 the expression depends on order of evaluation
Cause:
The expression modifies a variable more than once without an intervening sequence point OR
the expression modifies a variable and fetches its value in a computation that is not used to
4277 logical AND with a constant, do you mean to use '&'? 65