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

2.139 4299 64 bit migration: multiply result could be truncated before
cast to bigger sized type
Cause:
The size of the result of an operation is determined based on the size of the operands and not
based on size of variable in which the resultant value is stored. If the result exceeds the size of the
operands, in this case 32 bits, it will be truncated even before the assignment takes place.
Example:
void foo(int data) {
long data1 = data * 16; // warning 4299 here
long data2 = ((long)data) * 16; // no warning
}
Action:
If you expect the value of the result to exceed the size of the type of operands then cast the operands
to the bigger type before multiplication else use same type for operands and result.
Reference:
2.140 4300 Overflow while computing constant in left shift operation
Cause:
An overflow occurred while evaluating a constant in a left shift operation.
Example:
#define COUNT 24
#define ALPHA 0x0000EF
int main() {
int a = ALPHA << COUNT;
}
Action:
Correct the constant expression so that it does not overflow.
Reference:
2.141 4301 expression has no effect
Cause:
The expression has no effect or side-effect.
Example:
#define foo(A) 0
int main() {
int A = 0;
foo(A);
}
Action:
Remove or correct the expression. In some cases the expression 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:
2.142 4314 if statement without body, did you insert an extra ';'?
Cause:
The if statement does not have a body. No action is performed when the if condition is met.
2.139 4299 64 bit migration: multiply result could be truncated before cast to bigger sized type 65