Skip to content

Commit 37440ac

Browse files
committed
Fixed weakest precondition for code_assertt
The existing wp function treated an assert statement the same way as a skip statement. This commit fixes this behavior as per standard Hoare logic rules.
1 parent 751c986 commit 37440ac

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/goto-programs/wp.cpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,14 @@ exprt wp_assign(
213213
return pre;
214214
}
215215

216+
exprt wp_assert(
217+
const code_assertt &code,
218+
const exprt &post,
219+
const namespacet &)
220+
{
221+
return and_exprt(code.assertion(), post);
222+
}
223+
216224
exprt wp_assume(
217225
const code_assumet &code,
218226
const exprt &post,
@@ -250,7 +258,7 @@ exprt wp(
250258
else if(statement==ID_decl)
251259
return wp_decl(to_code_decl(code), post, ns);
252260
else if(statement==ID_assert)
253-
return post;
261+
return wp_assert(to_code_assert(code), post, ns);
254262
else if(statement==ID_expression)
255263
return post;
256264
else if(statement==ID_printf)

0 commit comments

Comments
 (0)