Frama-C-discuss mailing list archives

This page gathers the archives of the old Frama-C-discuss archives, that was hosted by Inria's gforge before its demise at the end of 2020. To search for mails newer than September 2020, please visit the page of the new mailing list on Renater.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Frama-c-discuss] [Jessie] Problem with simple search programm

  • Subject: [Frama-c-discuss] [Jessie] Problem with simple search programm
  • From: Boris.Hollas at (Hollas Boris (CR/AEY1))
  • Date: Wed, 25 Mar 2009 15:56:12 +0100


I try to verify the simple search programm below.

Running Simplify results in two ? signs:

- when I click on the first "?" labeled "postcondition", the following code is highlighted:

insVal(int a[], int aLength, int val) {
  int i = 0;

  //@ loop in

  I don't understand what that means. Is this a bug in gWhy's highlighting?

- the second "?" is labeled "pointer dereferencing" and corresponds to
      if(a[i] == val) return true;
  Does this mean that frama-c doesn't detect that i<aLength holds at this point?

What else should I annotate to verify the code?

With Spec#, Boogie and Z3 I was able to verify the C# version of this. gWhy with Z3 however didn't terminate (see


#define true 1
#define false 0
typedef int bool;

  requires \valid(a+ (0..aLength-1));
  ensures \result == true  <==>  \exists int j; 0 <= j <= aLength-1 && a[j] == val;
bool ContainsVal(int a[], int aLength, int val) {
  int i = 0;

  //@ loop invariant \forall int j; 0 <= j <= i-1 ==> a[j] != val;
  while(i<aLength) {
      if(a[i] == val) return true;
      else i++;
  return false;