Skip to content

Commit 443d4f0

Browse files
committed
Add non-determinism to array_address_of test
This test is intended to cover incremental SMT decision procedure support expressions of the form `address_of(array[0])`. These occur as part of the conversion from array to pointer, which may be implicitly introduced by applying `__CPROVER_OBJECT_SIZE` to an array. The existing test is not actually checking this conversion due to it being simplified away during constant propagation. The introduction of non-determinism in this commit prevents constant propagation from removing expressions of this form, so that their conversion will actually be tested.
1 parent 2181146 commit 443d4f0

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed
Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
int main()
22
{
3-
int example_array[10000];
4-
__CPROVER_assert(
5-
__CPROVER_OBJECT_SIZE(example_array) == 40000, "Array condition 1");
6-
__CPROVER_assert(
7-
__CPROVER_OBJECT_SIZE(example_array) == 40001, "Array condition 2");
3+
int example_array1[10000];
4+
int example_array2[10000];
5+
int *foo;
6+
int choice;
7+
if(choice)
8+
foo = example_array1;
9+
else
10+
foo = example_array2;
11+
__CPROVER_assert(__CPROVER_OBJECT_SIZE(foo) == 40000, "Array condition 1");
12+
__CPROVER_assert(__CPROVER_OBJECT_SIZE(foo) == 40001, "Array condition 2");
813
}

regression/cbmc-incr-smt2/arrays/array_address_of.desc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
CORE
22
array_address_of.c
3-
3+
--verbosity 10
44
Passing problem to incremental SMT2 solving
5+
address_of\(main\:\:1\:\:example_array1\!0\@1\[0\]\)
6+
address_of\(main\:\:1\:\:example_array2\!0\@1\[0\]\)
57
line \d+ Array condition 1: SUCCESS
68
line \d+ Array condition 2: FAILURE
79
^EXIT=10$

0 commit comments

Comments
 (0)