HP Code Advisor Diagnostics Reference Guide (5900-1865, July 2011)
int main() {
typedef struct {
uint32_t data_size;
uint8_t status;
} str;
}
Action:
Insertion of padding bytes themselves is not a problem but you need to ensure that you do not use
hard coded offsets for accessing fields of the struct through pointers, use offset of macro instead.
In some cases the number of padding bytes being inserted can be reduced by reordering the fields.
Reference:
ANSI/ISO C++ 18.1(5)
2.124 4272 conversion from %t1 to %t2 may lose sign
Cause:
The Compiler has detected conversion from a signed data type to an unsigned data type. This
may lead to loss of sign.
Example:
typedef unsigned int uint32_t;
void foo(int j) {
uint32_t k;
k = j;
}
Action:
If this is intended then add a cast.
Reference:
2.125 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:
2.126 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() {
60 Diagnostics Details