Skip to content

Commit 5383548

Browse files
author
Daniel Kroening
authored
Merge pull request #2880 from diffblue/struct-ptr-cast
add test for value set failure
2 parents 946abb8 + 5a12b54 commit 5383548

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

regression/cbmc/struct11/main.c

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#include <assert.h>
2+
3+
struct prefix
4+
{
5+
int integer;
6+
int *p;
7+
};
8+
9+
struct full_struct
10+
{
11+
int integer;
12+
int *p;
13+
int something_else;
14+
};
15+
16+
void full_to_prefix()
17+
{
18+
int some_int=1;
19+
struct full_struct f_s;
20+
f_s.integer=10;
21+
f_s.p=&some_int;
22+
struct prefix *prefix_p=(struct prefix *)&f_s;
23+
assert(prefix_p->integer==10);
24+
assert(*prefix_p->p==1);
25+
}
26+
27+
void prefix_to_full()
28+
{
29+
int some_int=1;
30+
struct prefix prefix;
31+
prefix.integer=10;
32+
prefix.p=&some_int;
33+
struct full_struct *f_s_p=(struct full_struct *)&prefix;
34+
assert(f_s_p->integer==10);
35+
assert(*f_s_p->p==1);
36+
}
37+
38+
int main()
39+
{
40+
full_to_prefix();
41+
prefix_to_full();
42+
}

regression/cbmc/struct11/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 value sets fail to track the pointer

0 commit comments

Comments
 (0)