Skip to content

Commit 9cd9d93

Browse files
author
Daniel Kroening
committed
added a test for the precision of the value sets on unions
1 parent 4898823 commit 9cd9d93

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

regression/cbmc/union10/union_list2.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#include <assert.h>
2+
3+
struct list_item
4+
{
5+
unsigned value;
6+
struct list_item *previous;
7+
};
8+
9+
struct List
10+
{
11+
unsigned something;
12+
struct list_item * index, end;
13+
};
14+
15+
union U
16+
{
17+
struct List my_list;
18+
};
19+
20+
int main() {
21+
union U u;
22+
23+
u.my_list.index = &u.my_list.end;
24+
struct list_item *p0 = u.my_list.index;
25+
u.my_list.end.value=123;
26+
u.my_list.end.previous = u.my_list.index;
27+
struct list_item *p1 = u.my_list.index;
28+
struct list_item *p2 = p1->previous;
29+
assert(p2!=0); // should pass
30+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
KNOWNBUG
2+
union_list2.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring

0 commit comments

Comments
 (0)