HP Code Advisor Diagnostics

The declaration of function has an empty parameter list. If the function has parameters, they
should be declared here; if it has no parameters,void should be specified in the parameter list.
Example: void foo(long (*compar) ()) ;
Action:
The recommended way to declare a function that takes no parameters is to use void in the
parameter list.
Reference:
4298 64 bit migration: addition 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 4298 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 addition else use same type for operands and result.
Reference:
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:
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() {
68 Diagnostics Details