Skip to content

Commit c2f986f

Browse files
committed
fix a bug with inclusion checking on havoc_object
The write set inclusion check on havoc_object(ptr) only checked the inclusion of (ptr+0) in the write set, but performed havocing of the entire object (i.e., ptr+0 until ptr+OBJECT_SIZE(ptr)). The proposed change fixes this behavior and checks the inclusion of the entire object in the write set.
1 parent 516f109 commit c2f986f

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

regression/contracts/assigns_enforce_20/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ main.c
33
--enforce-contract foo
44
^EXIT=10$
55
^SIGNAL=0$
6-
^\[foo.\d+\] line \d+ Check that \*y is assignable: FAILURE$
6+
^\[foo.\d+\] line \d+ Check that POINTER_OBJECT\((\(.+\))?y\) is assignable: FAILURE$
77
^\[foo.\d+\] line \d+ Check that x is assignable: FAILURE$
88
^VERIFICATION FAILED$
99
--

src/goto-instrument/contracts/contracts.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -942,8 +942,8 @@ void code_contractst::check_frame_conditions(
942942
instruction_it->is_other() &&
943943
instruction_it->get_other().get_statement() == ID_havoc_object)
944944
{
945-
const exprt &havoc_argument = dereference_exprt(
946-
to_typecast_expr(instruction_it->get_other().operands().front()).op());
945+
const auto havoc_argument =
946+
pointer_object(instruction_it->get_other().operands().front());
947947
add_inclusion_check(body, assigns, instruction_it, havoc_argument);
948948
}
949949
}

0 commit comments

Comments
 (0)