Skip to content

Commit f25e922

Browse files
committed
Value sets must not return an empty set for nondet symbols
Even when the expression type is not immediately a pointer, some component of the type may be a pointer. As such, it could legitimately appear in pointer dereferencing, and we should at least add "unknown" to the value set. This is a follow-up fix to 3789670: the regression test included yields a spurious counterexample in versions between 3789670 and this bugfix commit.
1 parent 9b72a5c commit f25e922

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include <stdlib.h>
2+
3+
struct S
4+
{
5+
int *p;
6+
int x;
7+
};
8+
9+
int main()
10+
{
11+
struct S *s = malloc(sizeof(struct S));
12+
// Guard must not be removed (deemed trivially true) by try_filter_value_sets.
13+
if(s->p != NULL)
14+
__CPROVER_assert(s->p != NULL, "cannot be NULL");
15+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CORE
2+
main.c
3+
4+
^VERIFICATION SUCCESSFUL$
5+
^EXIT=0$
6+
^SIGNAL=0$
7+
--
8+
^warning: ignoring
9+
--
10+
try_filter_value_sets must not end up in a situation where it deems the guard
11+
trivially true. This situation arises when the value set wrongly is empty.

src/pointer-analysis/value_set.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,8 @@ void value_sett::get_value_set_rec(
521521
exprt(ID_null_object, to_pointer_type(expr_type).subtype()),
522522
offsett());
523523
}
524+
else
525+
insert(dest, exprt(ID_unknown, original_type));
524526
}
525527
else if(expr.id()==ID_if)
526528
{

0 commit comments

Comments
 (0)