Skip to content

Commit 0ec4e7d

Browse files
authored
Merge pull request #2854 from diffblue/union-valueset-bug
added a test for the precision of the value sets on unions
2 parents 84170df + 9638dbb commit 0ec4e7d

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

regression/cbmc/union10/union_list2.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
{
22+
union U u;
23+
24+
u.my_list.index = &u.my_list.end;
25+
struct list_item *p0 = u.my_list.index;
26+
u.my_list.end.value = 123;
27+
u.my_list.end.previous = u.my_list.index;
28+
struct list_item *p1 = u.my_list.index;
29+
struct list_item *p2 = p1->previous;
30+
assert(p2 != 0); // should pass
31+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
KNOWNBUG
2+
union_list2.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring
9+
--
10+
Value sets do not record byte-extract operations with sufficient detail:
11+
struct list_item *p1 = u.my_list.index;
12+
struct list_item *p2 = p1->previous;
13+
yields
14+
(29) p1!0@1#2 == byte_extract_little_endian(u!0@1#4, 8l, struct list_item { unsigned int value; unsigned int $pad1; struct list_item *previous; } *)
15+
(30) p2!0@1#2 == p1$object#0.previous
16+
as
17+
main::1::p1 = { <integer_address, *, unsigned char> }
18+
is the only information stored in the value set.

0 commit comments

Comments
 (0)