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

Table Of Contents
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:
#include <stdio.h>
union endian { short s; int i; char c;};
int main() {
union endian u;
u.i = 0x01234567;
printf("%hx\n", u.s);
return 0;
}
cadvise displays the following warning when the option +Ww4365 is passed to it.
"/path/1.c", line 2: warning #4365-D: endian porting: the definition
of the union may be endian dependent
The field s is incompatible with field(s) i, c
The field i is incompatible with field(s) s, c
The field c is incompatible with field(s) s, i
union endian {
Action:
Avoid using unions to convert from one type to another of different size.
Reference:
4370 Control flows into the switch case from the previous case value
Cause:
Occurs when there is a fall-through case statement within a switch.
Example:
#include <stdio.h>
int foo(int a) {
switch (a) {
case 1: printf("One\n");
case 2: printf("Two\n");
break;
case 3: printf("Three\n");
case 4: printf("Four\n");
default: printf("Bye\n");
}
return 0;
}
Action:
This warning is issued to ensure that the missing breaks between the different case values is
expected.
Reference:
4372 Potential overflow in arithmetic expression involving time_t/clock_t
values
Cause:
When arithmetic expressions that involve time_t/clock_t values overflow, the code may behave
incorrectly.
Example:
#include <stdio.h>
4370 Control flows into the switch case from the previous case value 69