Skip to content

Commit 5658e34

Browse files
committed
Disallow enumerate equal expr between sub-exprs with different types.
1 parent 45d3399 commit 5658e34

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

src/goto-instrument/synthesizer/enumerative_loop_invariant_synthesizer.cpp

+8-2
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,14 @@ std::vector<exprt> construct_terminals(std::set<symbol_exprt> symbols)
4848
// For a variable v with primitive type, we add
4949
// v, __CPROVER_loop_entry(v)
5050
// into the result.
51-
result.push_back(e);
51+
result.push_back(typecast_exprt(e, size_type()));
5252
result.push_back(unary_exprt(ID_loop_entry, e, size_type()));
5353
}
54+
if((e.type().id() == ID_signedbv))
55+
{
56+
result.push_back(e);
57+
result.push_back(unary_exprt(ID_loop_entry, e, e.type()));
58+
}
5459
if((e.type().id() == ID_pointer))
5560
{
5661
// For a variable v with pointer type, we add
@@ -62,7 +67,8 @@ std::vector<exprt> construct_terminals(std::set<symbol_exprt> symbols)
6267
unary_exprt(ID_loop_entry, e, e.type()), size_type()));
6368
}
6469
}
65-
result.push_back(from_integer(1, size_type()));
70+
result.push_back(from_integer(1, unsigned_int_type()));
71+
result.push_back(from_integer(1, unsigned_long_int_type()));
6672
return result;
6773
}
6874

src/goto-instrument/synthesizer/expr_enumerator.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,12 @@ exprt binary_functional_enumeratort::instantiate(const expr_listt &exprs) const
316316
exprs.size() == 2,
317317
"number of arguments should be 2: " + integer2string(exprs.size()));
318318
if(op_id == ID_equal)
319+
{
320+
if(exprs.front().type() != exprs.back().type())
321+
return true_exprt();
322+
319323
return equal_exprt(exprs.front(), exprs.back());
324+
}
320325
if(op_id == ID_le)
321326
return less_than_or_equal_exprt(exprs.front(), exprs.back());
322327
if(op_id == ID_lt)

src/goto-programs/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ add_library(goto-programs ${sources})
33

44
generic_includes(goto-programs)
55

6-
target_link_libraries(goto-programs util assembler langapi analyses linking ansi-c)
6+
target_link_libraries(goto-programs util assembler langapi analyses linking ansi-c json)

0 commit comments

Comments
 (0)