#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void operator delete(void* ptr) { free(ptr); }
void* operator new(size_t sz) {
void *dst=malloc(sz);
if (dst) memset(dst,0xFF,sz);
return dst;
}
struct A { int x; A() {} };
struct B : A { int y; A a; };
int main(int argc,char** argv) {
A *a=new A();
B *b=new B();
printf("a->x=%d\n",a->x);
printf("b->x=%d\n",b->x);
printf("b->y=%d\n",b->y);
printf("b->a.x=%d\n",b->a.x);
delete b;
delete a;
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KI2luY2x1ZGUgPHN0cmluZy5oPgoKdm9pZCBvcGVyYXRvciBkZWxldGUodm9pZCogcHRyKSB7IGZyZWUocHRyKTsgfQp2b2lkKiBvcGVyYXRvciBuZXcoc2l6ZV90IHN6KSB7CiAgICB2b2lkICpkc3Q9bWFsbG9jKHN6KTsKICAgIGlmIChkc3QpIG1lbXNldChkc3QsMHhGRixzeik7CiAgICByZXR1cm4gZHN0Owp9CgpzdHJ1Y3QgQSB7IGludCB4OyBBKCkge30gfTsKc3RydWN0IEIgOiBBIHsgaW50IHk7IEEgYTsgfTsKCmludCBtYWluKGludCBhcmdjLGNoYXIqKiBhcmd2KSB7CiAgICBBICphPW5ldyBBKCk7CiAgICBCICpiPW5ldyBCKCk7CgogICAgcHJpbnRmKCJhLT54PSVkXG4iLGEtPngpOwogICAgcHJpbnRmKCJiLT54PSVkXG4iLGItPngpOwogICAgcHJpbnRmKCJiLT55PSVkXG4iLGItPnkpOwogICAgcHJpbnRmKCJiLT5hLng9JWRcbiIsYi0+YS54KTsKCiAgICBkZWxldGUgYjsKICAgIGRlbGV0ZSBhOwogICAgcmV0dXJuIDA7Cn0K