enum typeList {CHAR,INT,LONG};
enum typeList showType(void);
long int returnLong(void);
void main() {
int *p = (int *)0x32; //Green absolute address usage
enum typeList myType = showType();
char x_char;
int x_int;
long int x_long;
if(myType == CHAR)
x_char = *p;
else if(myType == INT)
x_int = *p;
else {
x_long = *p;
long int x2_long = returnLong();
}
}In this example, the option -no-assumption-on-absolute-addresses is
not used. Therefore, the Absolute address usage check
is green when the pointer p is assigned an absolute
address.
Following this check, the verification assumes that the address is initialized with an
int value. If you use x86_64 for
Target
processor type (-target) (sizeof(char) < sizeof(int) <
sizeof(long int)), the assumption results in the following:
In the if(myType == CHAR) branch, an orange
Overflow occurs because
x_char cannot accommodate
all values allowed for an
int variable.
In the else if(myType == INT) branch, if you place
your cursor on x_int in your verification results,
the tooltip shows that x_int potentially has
all values allowed for an
int variable.
In the else branch, if you place your cursor on
x_long, the tooltip shows that
x_long potentially has
all values allowed for an
int variable. If you place your cursor on
x2_long, the tooltip shows that
x2_long potentially has
all values allowed for a
long int variable. The range of values that
x2_long can take is wider than the values allowed
for an int variable in the same target.