Skip to content

Commit c50c69d

Browse files
authored
Merge pull request #5703 from tautschnig/union-test-1
Additional and updated union regression tests involving pointers
2 parents a0dbf74 + 9822aad commit c50c69d

File tree

3 files changed

+60
-1
lines changed

3 files changed

+60
-1
lines changed

regression/cbmc/union10/union_list2.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
KNOWNBUG
1+
CORE
22
union_list2.c
33

44
^EXIT=0$

regression/cbmc/union14/main.c

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
struct fatptr
2+
{
3+
int *data;
4+
unsigned long int len;
5+
};
6+
7+
struct slice
8+
{
9+
int *data;
10+
unsigned long int len;
11+
};
12+
13+
union repr {
14+
struct slice rust;
15+
struct fatptr raw;
16+
};
17+
18+
struct slice cast(int *data, unsigned long int len)
19+
{
20+
struct fatptr x;
21+
union repr z;
22+
x.data = data;
23+
x.len = len;
24+
z.raw = x;
25+
return z.rust;
26+
}
27+
28+
struct fatptr cast2(int *data, unsigned long int len)
29+
{
30+
struct slice w;
31+
union repr z;
32+
w.data = data;
33+
w.len = len;
34+
z.rust = w;
35+
return z.raw;
36+
}
37+
38+
int main()
39+
{
40+
int x = 256;
41+
42+
struct slice z = cast(&x, 1);
43+
struct fatptr z2 = cast2(&x, 1);
44+
45+
__CPROVER_assert(*z.data == 256, "test 1");
46+
__CPROVER_assert(*z2.data == 256, "test 2");
47+
}

regression/cbmc/union14/test.desc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
KNOWNBUG
2+
main.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring
9+
--
10+
Value sets do not properly track pointers through byte-extract operations. Thus
11+
derferencing yields __CPROVER_memory, which results in a spurious verification
12+
failure.

0 commit comments

Comments
 (0)