Skip to content

Commit 3a50362

Browse files
committed
Extend the previous test with an access to the array
The test currently fails an invariant in the array decision procedure.
1 parent 0e01c89 commit 3a50362

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

regression/cbmc/vla2/main.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#include <assert.h>
2+
3+
int main(int argc, char *argv[])
4+
{
5+
unsigned char x = argc;
6+
// make sure int multiplication below won't overflow - type casting to
7+
// unsigned long long would be possible, but puts yields a challenging problem
8+
// for the SAT solver
9+
__CPROVER_assume(x < 1ULL << (sizeof(int) * 8 / 2 - 1));
10+
11+
struct S
12+
{
13+
int a;
14+
int b[x];
15+
int c;
16+
};
17+
18+
if(x % 2 == 0)
19+
x = 3;
20+
21+
struct S s[x];
22+
23+
if((unsigned char)argc > 0)
24+
{
25+
s[0].b[0] = 42;
26+
assert(s[0].b[0] == 42);
27+
}
28+
29+
__CPROVER_assume(x < 255);
30+
++x;
31+
32+
assert(sizeof(struct S) == ((unsigned char)argc + 2) * sizeof(int));
33+
assert(sizeof(s) == (x - 1) * ((unsigned char)argc + 2) * sizeof(int));
34+
35+
return 0;
36+
}

regression/cbmc/vla2/test.desc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
KNOWNBUG
2+
main.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring
9+
--
10+
The array decision procedure does not yet handle member expressions.

0 commit comments

Comments
 (0)