File tree 2 files changed +63
-0
lines changed
regression/cbmc/memcpy-struct-ptr
2 files changed +63
-0
lines changed Original file line number Diff line number Diff line change
1
+ #include <string.h>
2
+ #include <assert.h>
3
+
4
+ struct without_ptr
5
+ {
6
+ int x ;
7
+ int y ;
8
+ };
9
+ struct with_int_ptr
10
+ {
11
+ int * i ;
12
+ int j ;
13
+ };
14
+ struct with_struct_ptr
15
+ {
16
+ struct without_ptr * s ;
17
+ int t ;
18
+ };
19
+
20
+ int main (int argc , char * * argv )
21
+ {
22
+ struct without_ptr w ;
23
+ w .x = 42 ;
24
+ w .y = 43 ;
25
+
26
+ struct without_ptr v ;
27
+ memcpy (& v , & w , sizeof (struct without_ptr ));
28
+ assert (v .x == 42 );
29
+ assert (v .y == 43 );
30
+
31
+ struct with_int_ptr k ;
32
+ k .i = (int * )44 ;
33
+ k .j = 45 ;
34
+
35
+ struct with_int_ptr m ;
36
+ memcpy (& m , & k , sizeof (struct with_int_ptr ));
37
+ assert (m .i == (int * )44 );
38
+ assert (m .j == 45 );
39
+
40
+ struct with_struct_ptr p ;
41
+ p .s = & w ;
42
+ p .t = 46 ;
43
+
44
+ struct with_struct_ptr q ;
45
+ memcpy (& q , & p , sizeof (struct with_struct_ptr ));
46
+ assert (q .s -> x == 42 );
47
+ assert (q .s -> y == 43 );
48
+ assert (q .t == 46 );
49
+
50
+ return 0 ;
51
+ }
Original file line number Diff line number Diff line change
1
+ KNOWNBUG
2
+ main.c
3
+ --bounds-check --pointer-check
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ ^VERIFICATION SUCCESSFUL$
7
+ ^\[main\.assertion\.5\] assertion q\.s->x == 42: SUCCESS$
8
+ ^\[main\.assertion\.6\] assertion q\.s->y == 43: SUCCESS$
9
+ --
10
+ ^warning: ignoring
11
+ --
12
+ Issue: 2925
You can’t perform that action at this time.
0 commit comments