|
Hi,
I am doing some experimentation with sscBoogie. I use it to verify one of the Spec# examples that counts non-null values in an array (code below). I introduced an error in the loop boundaries; the correct version is for (int i = 0; i < a.Length;
i++).
When verifying the program, sscBoogie fails to generate an array bound error. The erroneous code also violates the invariant which should produce an error. If I remove the invariants, sscBoogie detects the error! Any ideas why this is happening?
Thanks,
Iman
----------------------------------------------------------------------------------------------------------------------
public void CountNonNull()
{
expose(this){
int ct = 0;
for (int i = 0; i > a.Length; i++) // This is an erroneous loop!
invariant i <= a.Length; //infers 0<=i
invariant 0 <= ct && ct <= i; //needed to help verify next //invariant
invariant ct == count{int j in (0: i); (a[j]!=null)};
{
if (a[i]!=null) ct++;
}
count = ct;
}
}
|