【发布时间】:2020-10-13 16:10:04
【问题描述】:
我一直在用 c 语言编写一些基本程序,以使用 frama-c 工具进行验证。我想知道为什么该断言没有在程序中得到证明。提前致谢。
#include <limits.h>
/*@requires \valid(a) && \valid(b) && \separated(a,b);
assigns \nothing;
ensures (*a>*b ==> \result == *b) &&
(*b>=*a ==> \result == *a);
*/
int max_ptr(int* a,int* b){
return (*a>*b)?*b:*a;
}
extern int h;
//@assigns x;
int main(){
h=42;
int a=24;
int b=42;
//@assert h ==42;
int x;
x=max_ptr(&a,&b);
//@ assert x == 42;
//@ assert h ==42;
return 0;
}
所有预定目标都被成功证明,但断言声明除外:
//@ assert x == 42;
上面的断言超时了,函数合约需要修改吗?
【问题讨论】:
标签: proof frama-c preconditions post-conditions