Skip to content

Commit f8d2eb5

Browse files
Merge pull request diffblue#255 from diffblue/issue206
Avoid breaking fixpoint when merging data_dependency_context
2 parents 7d72dd2 + 26205ba commit f8d2eb5

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
void cal(void)
2+
{
3+
4+
}
5+
6+
const int g_N = 5;
7+
int x = 0;
8+
9+
struct {
10+
int idx;
11+
} s_str = { 0 };
12+
13+
void main(void)
14+
{
15+
for (int i = 0; i < g_N; i++) {
16+
cal();
17+
s_str.idx = s_str.idx + 1;
18+
}
19+
20+
__CPROVER_assert(s_str.idx > 1, "s_str.idx > 1");
21+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CORE
2+
main.c
3+
--dependence-graph-vs --structs --arrays --verify
4+
EXIT=0
5+
SIGNAL=0
6+
^\[main.assertion.1\] file .* function main, idx==1: Unknown$
7+
--

src/analyses/variable-sensitivity/data_dependency_context.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,13 @@ abstract_object_pointert data_dependency_contextt::merge(
228228
std::inserter(result->data_dominators, result->data_dominators.end()),
229229
location_ordert());
230230

231-
return result;
231+
// It is critically important that we only return a newly constructed result
232+
// abstract object *iff* the data has actually changed, otherwise AI may
233+
// never reach a fixpoint
234+
if(has_been_modified(result))
235+
return result;
236+
else
237+
return shared_from_this();
232238
}
233239

234240
return abstract_objectt::merge(other);

0 commit comments

Comments
 (0)