【发布时间】:2022-09-28 05:42:51
【问题描述】:
对于 Frama-C 和 WP 插件,用户如何断言程序中的某个点不可达?
寻找类似的东西:
//@ assert \\unreachable;
对于 Frama-C 和 WP 插件,用户如何断言程序中的某个点不可达?
寻找类似的东西:
//@ assert \\unreachable;
您可以使用//@ assert \false; 断言某个点不可达,因为:
一个(可证明的)不可到达的断言总是被证明是真的
通过Introduction to C program proof with Frama-C and its WP plugin 艾伦布兰查德。
例如对于给定文件
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-c25.0 版(锰)。
【讨论】: