I am looking for a method to perform widening on loops with no user hints. I'll explain using an example:
int z;
void main(void) {
int r = Frama_C_interval(0, MAX_INT);
z = 0;
for (int y=0; y<r; y++)
z++;
}
When running frama-c value analysis on this code, the global variable z receives the interval [--,--]. Because z was set to zero and the loop consists of an incremental operator, an automatic widening method should be able to deduct that the more accurate interval is [0, --]. Is it possible to do this in Frama-C?
No it doesn't:
This is a development version, but the same should apply to any version since signed overflow started to be treated as a serious error with ACSL alarm. If you are using a version from when signed overflow was assumed to harmlessly produce 2's complement results, 1) you should upgrade, it has been years and 2)
zcan hardly be argued to be trivially positive then (although it is positive because of a relational invariant linking the values ofzandywhile the loop is executing, relational invariant that the value analysis cannot represent).