The INFO C and C++ option provides general diagnostics about program
code and is not specific to migrations from ILP32 to LP64. Before
migrating, use the appropriate option to ensure that the following
items have been expunged from the code:
- Functions not prototyped - Function prototypes allow the compiler
to check for mismatched parameters.
- Functions not prototyped - Return parameter mis-matched, especially
when the code expects a pointer. (For example, malloc and family)
- Assignment of a long or a pointer to an int - This type of assignment
could cause truncation. Even assignments with an explicit cast will
be flagged.
- Assignment of an int to a pointer - If the pointer is referenced
it might be invalid.
Table 1. Example of diagnostic messages generated from code that is not
ready to be migrated from ILP32 to LP64Source: |
1 #include <stdio.h>
2 #include <limits.h>
3
4 void main(void) {
5 int foo_i;
6 long foo_l;
7 int *foo_pt;
8
9 foo_l = boo(1);
10 foo_l = foo_l << 1;
11 foo_l = 0xFFFFFFFF;
12 foo_l = (foo_l & 0xFFFFFFFF);
13 foo_l = LONG_MAX;
14 foo_l = (long)foo_i;
15 foo_i = (int) &foo_l;
16 foo_pt = (int *)foo_i;
17 }
18
19 long boo(long boo_l) {
20 return(boo_l);
21 }
|
Output: |
WARNING CCN3304 sample.c:9 No function prototype was
given for boo.
INFORMATIONAL CCN3419 sample.c:11 Converting 4294967295
to type long int does not preserve its value.
INFORMATIONAL CCN3438 sample.c:14 The value of the
variable foo_i may be used before being set.
INFORMATIONAL CCN3491 sample.c:17 The automatic
variable foo_pt is set but never referenced.
WARNING CCN3343 sample.c:19 Redeclaration of boo
differs from the declaration on line 9 of
/home/ts43218/sample2.c.
INFORMATIONAL CCN3050 sample.c:19 Return type long
in the redeclaration is not compatible with the
previous return type int.
INFORMATIONAL CCN3470 sample.c:21 Function main should
return int, not void.
|
Note: Lines 9,11 and
14 are affected by porting the code to LP64.
|