HP Code Advisor Diagnostics

4231 64 bit migration: conversion between types of different sizes has
occurred (from %t1 to %t2 )
Cause:
The compiler has detected conversion between data types having different sizes. This usually
happens when converting from int data type to pointer or long data type and vice versa. This is
not a problem in 32 bit mode since int, long and pointer all are of same size (32 bit) but in 64 bit
mode int is 32 bit whereas long and pointer are 64 bit. Because of the difference in size n 64 bit
mode this conversion might lead to incorrect behavior in 64 bit mode.
Example:
void foo(int i) {
foo((void*)i);
return i;
}
Action:
For 64 bit portability ensure that your code does not convert from int to pointer or long and vice
versa.
Reference:
4232 conversion from %t1 to a more strictly aligned type %t2 may cause
misaligned access
Cause:
A pointer is being cast from a lesser aligned type to a more strictly aligned type. Accesses using
the new type may cause misaligned access.
Example:
int foo(int* p, long long* l) {
l = (long long*) p; // warning 4232 here
}
Action:
Correct the code that uses such conversions.
Reference:
ANSI/ISO C++ 3.9, 3.9.1, 3.9.2
4235 conversion from %t1 to %t2 may lose significant bits
Cause:
The destination of an assignment has less range/precision than the source operand, this might
cause a loss of value/precision.
Example:
int i = 10;
double l = 10.345;
int j = l/i;
Action:
Change the type of the destination or if the loss in significant bits is not a concern add a cast.
Reference:
58 Diagnostics Details