On 08/16/10 23:16, Eric Blake wrote:
> The problem is how do we provide a working offsetof replacement, given
> that there is no way using standard C89 or C++ constructs to do it?  All
> implementations either use something like this which abuses undefined
> behavior within the standard but works without warning for that compiler:
> #define offsetof(__a,__b) ((size_t)(&(((__a*)0)->__b)))

That's a perfectly reasonable replacement, for compilers
where offsetof is broken.  It works for all such compilers that
we know of.  If some new compiler comes up, we can deal with it
then.

Also, unless this offsetof bug occurs in real code, it might
be better to not worry about it.  The bug is a noisy compile-time
bug, so it's not like we have to explicitly test for
it and make some noise on our own.

Reply via email to