This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
IE it's not legal in C to do something like this:>
struct foobase { int b; }; struct foo { int a; struct foobase b; };
void func (struct foobase *a) { struct foo *b = (struct foo *)(((char *)a) - (offsetof (foo, b) - offsetof (foo, a);
/* Yay, i've got a struct foo * back! */ if (b->a ! 5) abort(); }
int main(void) { struct foo a; a.a = 5; func(&a.b); return 0; }
struct foo { struct foobase b; int a; }
void func (struct foobase *a) { struct foo *b = (struct foo *) a; if (b->a != 5) abort (); }
-- Mark Mitchell CodeSourcery, LLC mark@codesourcery.com (916) 791-8304
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |