HP Code Advisor Diagnostics

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:
4229 64 bit migration: conversion from %t1 to %t2 may truncate value
Cause:
The compiler has detected conversion between pointers to data types having different sizes. This
usually happens when assigning an int pointer to a long pointer or 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 in 64 bit mode
this conversion might lead to incorrect behavior in 64 bit mode.
Example:
void foo(long l) {
int i = l;
}
Action:
For 64 bit portability ensure that your code does not convert from pointer and long values to int.
Reference:
4230 64 bit migration: conversion from %t1 to %t2 may cause target of
pointers to have a different size.
Cause:
The compiler has detected conversion between pointers to data types having different sizes. This
usually happens when assigning an int pointer to a long pointer or 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 in 64 bit mode
this conversion might lead to incorrect behavior in 64 bit mode.
Example:
long l = 1;
long *lptr = &l;
int *iptr = (int *)lptr;
Action:
For 64 bit portability ensure that your code does not convert from pointer to int to pointer to
long and vice versa.
Reference:
4229 64 bit migration: conversion from %t1 to %t2 may truncate value 57