HP-UX Cadvise Diagnostics Reference Guide (5900-1865, August 2012)

Table Of Contents
} object;
Action:
Declare the member functions to return a const handle instead.
Reference:
4289 endian porting: the definition of the union may be endian dependent
Cause:
The values accessed using the members of a union may differ based on endianness of a machine
in which the code is executed. This occurs when the union has members of different sizes, and
when the value stored using one member is accessed using another of a different size.
Example:
union Endian { char c[4]; int v; }; // warning 4289 here
int foo() {
union Endian u = { 0x11, 0x22, 0x33, 0x44 };
int i = u.v;
return i;
}
// On a big endian machine value of i will be 0x11223344 whereas
// on a little endian machine it will be 0x44332211
Action:
For portable code, change the way this union is used. Do not use unions for converting values
from one type to another.
Reference:
4290 endian porting: the initialization of char array may be endian
dependent
Cause:
A char array is being initialized using hexadecimal values. It is likely that this array will later be
accessed as an integer. Based on endianness of a machine on which code is executed the value
of this integer will differ.
Example:char a[4] = { 0x11, 0x22, 0x33, 0x44 }; // warning 4290 here
Action:
For portable code, check how this array is used.
Reference:
4292 endian porting: the dereference of cast pointer may be endian
dependent
Cause:
A pointer of integral type is being cast to a pointer of char or smaller integer type. Based on
endianness of a machine on which code is executed the value accessed using will differ.
Example:
unsigned int value = 0x03020100;
unsigned int *ptr =
unsigned char charVal;
void foo() {
charVal = *(unsigned char *)ptr; // warning 4292 here
charVal = *(unsigned char *)(void*)ptr; // no warning
}
4289 endian porting: the definition of the union may be endian dependent 63