1 /*
2    bug-2646174.c
3 */
4 
5 #include <testfwk.h>
6 
7 #include <string.h>
8 
9 struct foo1
10 {
11   int x;
12   int y;
13 };
14 
15 struct foo2
16 {
17   struct foo1 base_position;
18   struct foo1 direction;
19 };
20 
21 void
f(struct foo1 * a,const struct foo2 * d)22 f(struct foo1 *a, const struct foo2 *d)
23 {
24   memcpy(a, &(d->direction), sizeof(struct foo1));
25 }
26 
27 void
test_2646174(void)28 test_2646174(void)
29 {
30   struct foo2 x;
31   struct foo1 y;
32   y.x = 0;
33   x.direction.x = 1;
34   f(&y, &x);
35   ASSERT( y.x == 1 );
36 }
37 
38