Skip to content

Commit 48b8c90

Browse files
author
Thomas Kiley
authored
Merge pull request #5295 from thk123/array-equal-type-mismatch
Array equal type mismatch
2 parents 8911c0a + d1ddad6 commit 48b8c90

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed

regression/cbmc/Array_operations1/main.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,33 @@ void test_equal()
1212
__CPROVER_assert(array1[index] == array2[index], "arrays are equal");
1313
}
1414

15+
void test_unequal()
16+
{
17+
int a1[10];
18+
int a2[16];
19+
20+
__CPROVER_assert(
21+
!__CPROVER_array_equal(a1, a2), "different sizes arrays are unequal");
22+
__CPROVER_assert(__CPROVER_array_equal(a1, a2), "expected to fail");
23+
24+
float a3[10];
25+
void *lost_type1 = a1;
26+
void *lost_type3 = a3;
27+
28+
__CPROVER_assert(
29+
!__CPROVER_array_equal(lost_type1, lost_type3),
30+
"different typed arrays are unequal");
31+
__CPROVER_assert(
32+
__CPROVER_array_equal(lost_type1, lost_type3), "expected to fail");
33+
34+
int a4[10];
35+
int a5[10];
36+
37+
// Here the arrays both can be equal, and be not equal, so both asserts should fail
38+
__CPROVER_assert(!__CPROVER_array_equal(a4, a5), "expected to fail");
39+
__CPROVER_assert(__CPROVER_array_equal(a4, a5), "expected to fail");
40+
}
41+
1542
void test_copy()
1643
{
1744
char array1[100], array2[100], array3[90];
@@ -54,4 +81,5 @@ int main()
5481
test_copy();
5582
test_replace();
5683
test_set();
84+
test_unequal();
5785
}

regression/cbmc/Array_operations1/test.desc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,15 @@ main.c
44
^EXIT=10$
55
^SIGNAL=0$
66
^\[test_copy\.assertion\.4\] .* expected to fail: FAILURE$
7-
^\*\* 1 of 8 failed
7+
^\[test_unequal\.assertion\.1\] .* different sizes arrays are unequal: SUCCESS
8+
^\[test_unequal\.assertion\.2\] .* expected to fail: FAILURE
9+
^\[test_unequal\.assertion\.3\] .* different typed arrays are unequal: SUCCESS
10+
^\[test_unequal\.assertion\.4\] .* expected to fail: FAILURE
11+
^\[test_unequal\.assertion\.5\] .* expected to fail: FAILURE
12+
^\[test_unequal\.assertion\.6\] .* expected to fail: FAILURE
13+
^\*\* 5 of 14 failed
814
^VERIFICATION FAILED$
915
--
1016
^warning: ignoring
17+
--
18+
Verify the properties of various cprover array primitves

src/goto-symex/symex_other.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ void goto_symext::symex_other(
240240

241241
// check for size (or type) mismatch
242242
if(array1.type() != array2.type())
243-
assignment.lhs() = false_exprt();
243+
assignment.rhs() = false_exprt();
244244

245245
symex_assign(state, assignment);
246246
}

0 commit comments

Comments
 (0)