analyzer icon indicating copy to clipboard operation
analyzer copied to clipboard

Interval domain: Add wrap-around behavior

Open jerhard opened this issue 5 years ago • 2 comments

Goal

The interval domain should be improved by supporting wrap-arounds when possible, instead of going to top when a wrap around occurs.

For unsigned integer types, handling wrap-arounds precisely (when possible) should be the default (and only) behavior. For signed integer types, the precise handling should only be activated when ana.int.wrap_on_signed_overflow is enabled.

Example

E.g., the interval domain should be able to handle something like the following pseudo code:

unsinged int x = MAX_INT; //MAX_INT for unsigned
int top;
if(top){
  x--;
} 
//[x -> [MAX_INT-1; MAX_INT]]
x = x + 2;
//[x -> [0; 1]

jerhard avatar Jan 19 '21 10:01 jerhard

Is the plan here to then also add intervals [a,b] that are not normal in the sense that a <= b? I guess in most cases (except the one you constructed above where there is a must-overflow), the result of operations will be such non-normal intervals.

michael-schwarz avatar Jan 19 '21 11:01 michael-schwarz

Is the plan here to then also add intervals [a,b] that are not normal in the sense that a <= b?

No, I wouldn't plan to implement "circular intervals" here, because I think that would complicate the implementation quite a bit. It would only be for must-overflows.

jerhard avatar May 11 '21 08:05 jerhard

This is already implemented with setting the option sem.int.signed_overflow assume_wraparound.

jerhard avatar Jun 07 '23 12:06 jerhard