This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Bug report
- From: LN <lutz dot nitzsche at iga-gmbh dot de>
- To: "'gcc-bugs at gcc dot gnu dot org'" <gcc-bugs at gcc dot gnu dot org>
- Date: Thu, 12 Jun 2003 18:35:23 +0200
- Subject: Bug report
Dear GNUs...
I think that I have found a bug when compiling the macro 'offsetof'
for example
struct TYPE
{
int MEMBER;
int MEMBER2;
};
offsetof (TYPE,MEMBER)
allways raises
warning: invalid access to non-static data member 'TYPE::MEMBER' of NULL Object
warning: perhaps the 'offsetof' macro was uses incorrectly
a workaround is to change the declaration in stddef.h changing the NULL-pointer to
a NOT NULL address:
#define offsetof(TYPE, MEMBER) (((size_t) &((TYPE *)8)->MEMBER)-8)
If you think that checking for NULL pointers is usefull and necessary at this point,
you should fix that workaround in stddef.h or implement the 'offsetof' macro as a real
C++ operator.
with best regards
Lutz Nitzsche