bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] test-stddef: test offsetof compliance


From: Paul Eggert
Subject: Re: [PATCH] test-stddef: test offsetof compliance
Date: Mon, 16 Aug 2010 23:52:49 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.11) Gecko/20100713 Thunderbird/3.0.6

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

[Prev in Thread] Current Thread [Next in Thread]