I'm using Frama-C version Silicon-20161101. Every time a reference a pointer value *x
in an ensures clause the preprocessor inserts *\old(x)
unnecessarily. For example
// File swap.c:
/*@ requires \valid(a) && \valid(b);
@ ensures A: *a == \old(*b) ;
@ ensures B: *\at(\old(b),Post) == \old(*a) ;
@ assigns *a,*b ;
@*/
void swap(int *a,int *b)
{
int tmp = *a ;
*a = *b ;
*b = tmp ;
return ;
}
when processed with frama-c swap.c -print
outputs
/* Generated by Frama-C */
/*@ requires \valid(a) ∧ \valid(b);
ensures A: *\old(a) ≡ \old(*b);
ensures B: *\old(b) ≡ \old(*a);
assigns *a, *b;
*/
void swap(int *a, int *b)
{
int tmp;
tmp = *a;
*a = *b;
*b = tmp;
return;
}
Interestingly enough, this is still verified as correct by the WP plugin! I assume this is because *\old(a)
is the post value of \old(a)
(which is still the same pointer since it hasn't been changed)? Is this a bug? Is there any quick user end fix for this?