Skip to content

Commit c2d5ed5

Browse files
committed
goto_checkt: keep same-assertion for different expressions
Purging redundant assertions results in surprising user output as it would seem that certain properties aren't being checked.
1 parent 4bbd1c9 commit c2d5ed5

File tree

5 files changed

+28
-9
lines changed

5 files changed

+28
-9
lines changed

regression/cbmc/Pointer_byte_extract5/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ main.i
44
^EXIT=10$
55
^SIGNAL=0$
66
array\.List dynamic object upper bound in p->List\[2\]: FAILURE
7-
\*\* 1 of 14 failed
7+
\*\* 1 of \d+ failed
88
--
99
^warning: ignoring
1010
--

regression/cbmc/Undefined_Shift1/test.desc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ main.c
44
^EXIT=10$
55
^SIGNAL=0$
66
^\[.*\] line 4 shift operand is negative in .*: SUCCESS$
7+
^\[.*\] line 5 shift operand is negative in .*: SUCCESS$
78
^\[.*\] line 7 shift distance too large in .*: FAILURE$
89
^\[.*\] line 15 shift distance is negative in .*: FAILURE$
910
^\[.*\] line 15 shift distance too large in .*: SUCCESS$
1011
^\[.*\] line 20 shift operand is negative in .*: FAILURE$
11-
^\*\* 3 of 5 failed
12+
^\*\* 3 of 6 failed
1213
^VERIFICATION FAILED$
1314
--
1415
^warning: ignoring
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
CORE broken-smt-backend
2+
main.c
3+
--pointer-overflow-check --no-simplify
4+
^\[main.pointer_arithmetic.\d+\] line 6 pointer arithmetic: pointer outside dynamic object bounds in p \+ \(signed (long (long )?)?int\)10: FAILURE
5+
^\[main.pointer_arithmetic.\d+\] line 7 pointer arithmetic: pointer outside dynamic object bounds in p - \(signed (long (long )?)?int\)10: FAILURE
6+
^\[main.pointer_arithmetic.\d+\] line 10 pointer arithmetic: pointer outside object bounds in arr \+ \(signed (long (long )?)?int\)10: FAILURE
7+
^\[main.pointer_arithmetic.\d+\] line 11 pointer arithmetic: pointer outside object bounds in arr - \(signed (long (long )?)?int\)10: FAILURE
8+
^\*\* 4 of \d+ failed
9+
^VERIFICATION FAILED$
10+
^EXIT=10$
11+
^SIGNAL=0$
12+
--
13+
^warning: ignoring
14+
Invariant check failed
15+
--
16+
Uses --no-simplify to avoid removing repeated ASSERT FALSE statements.
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
CORE broken-smt-backend
1+
CORE
22
main.c
3-
--pointer-overflow-check --no-simplify
3+
--pointer-overflow-check
44
^\[main.pointer_arithmetic.\d+\] line 6 pointer arithmetic: pointer outside dynamic object bounds in p \+ \(signed (long (long )?)?int\)10: FAILURE
55
^\[main.pointer_arithmetic.\d+\] line 7 pointer arithmetic: pointer outside dynamic object bounds in p - \(signed (long (long )?)?int\)10: FAILURE
66
^\[main.pointer_arithmetic.\d+\] line 10 pointer arithmetic: pointer outside object bounds in arr \+ \(signed (long (long )?)?int\)10: FAILURE
@@ -12,5 +12,3 @@ main.c
1212
--
1313
^warning: ignoring
1414
Invariant check failed
15-
--
16-
Uses --no-simplify to avoid removing repeated ASSERT FALSE statements.

src/analyses/goto_check.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ class goto_checkt
242242
const guardt &guard);
243243

244244
goto_programt new_code;
245-
typedef std::set<exprt> assertionst;
245+
typedef std::set<std::pair<exprt, exprt>> assertionst;
246246
assertionst assertions;
247247

248248
/// Remove all assertions containing the symbol in \p lhs as well as all
@@ -333,8 +333,12 @@ void goto_checkt::invalidate(const exprt &lhs)
333333

334334
for(auto it = assertions.begin(); it != assertions.end();)
335335
{
336-
if(has_symbol(*it, find_symbols_set) || has_subexpr(*it, ID_dereference))
336+
if(
337+
has_symbol(it->second, find_symbols_set) ||
338+
has_subexpr(it->second, ID_dereference))
339+
{
337340
it = assertions.erase(it);
341+
}
338342
else
339343
++it;
340344
}
@@ -1545,7 +1549,7 @@ void goto_checkt::add_guarded_property(
15451549
? std::move(simplified_expr)
15461550
: implies_exprt{guard.as_expr(), std::move(simplified_expr)};
15471551

1548-
if(assertions.insert(guarded_expr).second)
1552+
if(assertions.insert(std::make_pair(src_expr, guarded_expr)).second)
15491553
{
15501554
auto t = new_code.add(
15511555
enable_assert_to_assume ? goto_programt::make_assumption(

0 commit comments

Comments
 (0)