Skip to content

Commit 4f660c4

Browse files
authored
Merge pull request #7602 from qinheping/bugfix/synthesis-for-empty-loops
Ignore empty loops during loop-contracts synthesis
2 parents 37d57b3 + 898efa9 commit 4f660c4

File tree

4 files changed

+25
-1
lines changed

4 files changed

+25
-1
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
void exit(int s)
2+
{
3+
_EXIT:
4+
goto _EXIT;
5+
}
6+
7+
int main()
8+
{
9+
exit(1);
10+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CORE
2+
main.c
3+
--pointer-check
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
--
9+
Check if empty loops are correctly skipped.

src/goto-instrument/contracts/contracts.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -869,7 +869,8 @@ void code_contractst::apply_loop_contract(
869869
for(const auto &loop_head_and_content : natural_loops.loop_map)
870870
{
871871
const auto &loop_content = loop_head_and_content.second;
872-
if(loop_content.empty())
872+
// Skip empty loops and self-looped node.
873+
if(loop_content.size() <= 1)
873874
continue;
874875

875876
auto loop_head = loop_head_and_content.first;

src/goto-synthesizer/enumerative_loop_contracts_synthesizer.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ void enumerative_loop_contracts_synthesizert::init_candidates()
8888
// Initialize invariants for unannotated loops as true
8989
for(const auto &loop_head_and_content : natural_loops.loop_map)
9090
{
91+
// Ignore empty loops and self-looped node.
92+
if(loop_head_and_content.second.size() <= 1)
93+
continue;
94+
9195
goto_programt::const_targett loop_end =
9296
get_loop_end_from_loop_head_and_content(
9397
loop_head_and_content.first, loop_head_and_content.second);

0 commit comments

Comments
 (0)