Skip to content

Commit 1b34d7c

Browse files
committed
fix recording old variant value at the beginning of loop body
1 parent dc99037 commit 1b34d7c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/goto-instrument/contracts/contracts.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,10 @@ void code_contractst::check_apply_loop_contracts(
209209
converter.goto_convert(old_decreases_assignment, havoc_code, mode);
210210
}
211211

212-
goto_function.body.destructive_insert(std::next(loop_head), havoc_code);
212+
const auto head_loc = loop_head->source_location();
213+
while(loop_head->source_location() == head_loc)
214+
loop_head = std::next(loop_head);
215+
goto_function.body.destructive_insert(loop_head, havoc_code);
213216
}
214217

215218
// Generate: assert(invariant) just after the loop exits

0 commit comments

Comments
 (0)