User's Manual
Example 59 Signed bit field of length 1
Cadvise warns cases where signed bit field of length 1 is being used and then assigned with a
value, which is excessive of its size.
For example, see the tags in the following code:
$ cat bitfield.c
struct { int bit:1; } s;
void test()
{
s.bit = 1;
}
In such cases, cadvise generates the following warnings:
"bitfield.c", line 1: warning #2108-D: signed bit field of length 1
struct { int bit:1; } s;
^
"bitfield.c", line 5: warning #4251-D: the assignment has an excessive
size for a bit field
s.bit = 1;
^
8.3 Detecting 32-bit to 64-bit migraton issues
The +w64bit option enables warnings that help detection of potential problems in converting
32-bit applications to 64-bit. The +w64bit option applies only to a 64-bit compile (using
+DD64). This option is equivalent to the +M2 option. Following are some of the checks performed
by this option:
• 64–bit value is implicitly converted to a 32 bit value, for example, long to int.
• Pointer to a 4-byte aligned object is implicitly converted to a pointer to a 8-byte aligned object.
For example, see the following code:
Example 60 Detecting 32–bit to 64–bit migraton issues
$ cat convert.c
int *int_to_ptr (int i)
{
return (int *)i;
}
In such cases, cadvise generates the following warning:
"convert.c", line 3: warning #4231-D: 64 bit migration: conversion
between types of different sizes has occurred
(from "int" to "int *" )
return (int *)i;
^
8.4 Detecting endianness migration issues
The +wendian option helps you to detect code fragments which are endian dependent. The
following example shows the detection of endian dependent code fragments.
8.3 Detecting 32-bit to 64-bit migraton issues 51