Skip to content

Commit 21fa6a0

Browse files
Merge pull request #7108 from thomasspriggs/tas/fix_address_of_zero_test
Add non-determinism to array_address_of test
2 parents 6259f6c + 1b5fa34 commit 21fa6a0

File tree

4 files changed

+49
-6
lines changed

4 files changed

+49
-6
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
int main()
2+
{
3+
int example_array1[10000];
4+
char example_array2[20000];
5+
void *foo;
6+
__CPROVER_bool choice = nondet___CPROVER_bool();
7+
if(choice)
8+
foo = example_array1;
9+
else
10+
foo = example_array2;
11+
__CPROVER_assert(
12+
foo != example_array1 || __CPROVER_OBJECT_SIZE(foo) == 40000,
13+
"Array condition 1");
14+
__CPROVER_assert(__CPROVER_OBJECT_SIZE(foo) == 40000, "Array condition 2");
15+
__CPROVER_assert(
16+
foo != example_array2 || __CPROVER_OBJECT_SIZE(foo) == 20000,
17+
"Array condition 3");
18+
__CPROVER_assert(__CPROVER_OBJECT_SIZE(foo) == 20000, "Array condition 4");
19+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
CORE
2+
address_of_two_array_sizes.c
3+
--verbosity 10
4+
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\]\)
7+
line \d+ Array condition 1: SUCCESS
8+
line \d+ Array condition 2: FAILURE
9+
line \d+ Array condition 3: SUCCESS
10+
line \d+ Array condition 4: FAILURE
11+
^EXIT=10$
12+
^SIGNAL=0$
13+
--
14+
--
15+
Test that __CPROVER_OBJECT_SIZE returns the expected results in the case where
16+
the pointer passed to it may point to one of 2 arrays, where each array has a
17+
different size.
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)