OSDN Git Service

Backported from mainline
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.c-torture / execute / 920810-1.c
1 #include <stdio.h>
2 #include <string.h>
3 #include <stdlib.h>
4
5 typedef struct{void*super;int name;int size;}t;
6 t*f(t*clas,int size)
7 {
8   t*child=(t*)malloc(size);
9   memcpy(child,clas,clas->size);
10   child->super=clas;
11   child->name=0;
12   child->size=size;
13   return child;
14 }
15 main()
16 {
17   t foo,*bar;
18   memset(&foo,37,sizeof(t));
19   foo.size=sizeof(t);
20   bar=f(&foo,sizeof(t));
21   if(bar->super!=&foo||bar->name!=0||bar->size!=sizeof(t))abort();
22   exit(0);
23 }