Skip to content

Commit 5e907b0

Browse files
committed
Fix byte update of struct/array elements
A key part of this is factoring out code that was almost-the-same from lower_byte_update_array_vector and lower_byte_update_struct, but actually had subtle bugs as documented in regression test included in this commit. For consistency, do all offset calculations in bits rather than flipping back and forth between bits and bytes.
1 parent d84744f commit 5e907b0

File tree

3 files changed

+278
-194
lines changed

3 files changed

+278
-194
lines changed

regression/cbmc/byte_update18/main.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
struct S
2+
{
3+
unsigned char A[1];
4+
char len; // keep this to reproduce
5+
};
6+
7+
struct O
8+
{
9+
struct S A[2];
10+
char len; // this is key to reproduce
11+
};
12+
13+
int main()
14+
{
15+
struct O t = {{{{0}, 2}, {{42}, 2}}, 2};
16+
unsigned n;
17+
__CPROVER_assume(n < 2);
18+
__CPROVER_assume(n > 0);
19+
char src_n[n];
20+
__CPROVER_array_replace((char *)t.A[0].A, src_n);
21+
__CPROVER_assert(t.A[1].A[0] == 42, "");
22+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CORE broken-cprover-smt-backend
2+
main.c
3+
4+
^VERIFICATION SUCCESSFUL$
5+
^EXIT=0$
6+
^SIGNAL=0$
7+
--
8+
^warning: ignoring
9+
--
10+
Some bug in our in-tree SMT2 solver makes it report SAT, when Z3 states that the
11+
same SMT2 formula is (as expected) UNSAT.

0 commit comments

Comments
 (0)