I have been trying to reason about a loop over a dinamically-allocated array with a non-deterministic size, but I haven't been able to convince Frama-C/Eva of the\validity of memory that is returned by malloc.
After boiling it down to:
#include <stdio.h>
#include <stdlib.h>
#include "__fc_builtin.h"
int main(void) {
int i,sz; char*arr;
sz = Frama_C_interval(1,2);
arr = (char*) malloc(sz*sizeof(char));
arr[0]='a';
arr[sz-1]='b';
}
when run in Frama-C 24.0 Chromium/amd64 with opts frama-c -eva -eva-no-alloc-returns-null, Eva fails to prove that \valid(arr+sz-1).
I am quite intrigued about why this is the case as everything seems ok in the intermediate values.
When replacing sz for a concrete size (1 or 2 for instance) the proof goes trivially.