This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/30368] wrong result
- From: "pinskia at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 5 Jan 2007 20:13:24 -0000
- Subject: [Bug c/30368] wrong result
- References: <bug-30368-11381@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #3 from pinskia at gcc dot gnu dot org 2007-01-05 20:13 -------
> anther, consider an example definite[2] of 'offsetof', if you think
> that is undefined, it's almost impossible to give a definite of
> offsetof.
> #define offsetof(TYPE,MEMBER) ((size_t)&((TYPE*)0)->MEMBER)
The C standard still says that is undefined. See 6.5.3.2/4.
Also GCC has a builtin for offsetof to get around the undefinedness of the
above.
You can also define offsetof like:
#define offsetof(TYPE,MEMBER) (((size_t)&((TYPE*)128)->MEMBER) - 128)
Which gets around the undefined issue.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30368