HP Code Advisor Diagnostics Reference Guide (5900-1865, July 2011)
The bitwise operator | has lower precedence than the comparison operator, possibly changing
the semantics of the expression. This can be caused by other combinations of comparison and
bitwise operators as well.
Example:
bool check(unsigned p1, unsigned p2, unsigned mask) {
return ( p1 == p2 | mask );
}
Action:
Disambiguate the expression by using explicit parenthesis around the bitwise operator, thus return
( p1 == (p2 | mask) );
Reference:
2.102 4227 padding struct with %s1 bytes to align member %sq2
Cause:
The compiler has added s1 bytes before a member so that it will be aligned and hence accessed
efficiently.
Example:
typedef struct {
int field1;
double field2;
} 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:
2.103 4228 64 bit migration: conversion from %t1 to a more strictly
aligned type %t2 may cause misaligned access
Cause:
The compiler has detected conversion of pointers from a lesser aligned type to a more strictly
aligned type. This usually happens when assigning an int pointer to a long pointer. This is not a
problem in 32 bit mode since int and long are both 4 bytes aligned but in 64 bit mode int is 4
byte aligned whereas long is 8 bytes aligned. Because of the difference in alignment in 64 bit
mode this conversion might cause unaligned access in 64 bit mode.
Example:
int a = 10;
long *lptr = (long *)&a;
Action:
For 64 bit portability ensure that your code does not assign a pointer to int to a pointer to long.
Reference:
2.104 4229 64 bit migration: conversion from %t1 to %t2 may truncate
value
Cause:
2.102 4227 padding struct with %s1 bytes to align member %sq2 53