[英]How to assert that a point is unreachable?
對於 Frama-C 和 WP 插件,用戶如何斷言程序中的某個點不可達?
尋找類似的東西:
//@ assert \unreachable;
您可以使用//@ assert \false;
對於一個點不可達的斷言,因為:
一個(可證明的)不可到達的斷言總是被證明是真的
通過 Allan Blanchard的 Frama-C 及其 WP 插件介紹 C 程序證明。
例如對於給定的文件main.c
:
/*@
assigns \nothing;
*/
int foo(const int input) {
int result = 0;
if (input > 0) {
result += 1;
if (input < 0) {
// This assertion will be proved successfully
// because this location is provably unreachable.
//@ assert \false;
result += 1;
}
}
return result;
}
驗證斷言是否被證明:
$ frama-c -wp main.c
[kernel] Parsing main.c (with preprocessing)
[wp] Warning: Missing RTE guards
[wp] 3 goals scheduled
[wp] Proved goals: 3 / 3
Qed: 3
以上使用的是frama-c
25.0版(錳)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.