[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] test-stddef: test offsetof compliance
From: |
Eric Blake |
Subject: |
Re: [PATCH] test-stddef: test offsetof compliance |
Date: |
Mon, 16 Aug 2010 17:28:12 -0600 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.7) Gecko/20100720 Fedora/3.1.1-1.fc13 Lightning/1.0b2pre Mnenhy/0.8.3 Thunderbird/3.1.1 |
On 08/16/2010 05:25 PM, Bruno Haible wrote:
> Eric,
>
> Paul Eggert wrote:
>> unless this offsetof bug occurs in real code, it might
>> be better to not worry about it.
>
> I agree. It's the first time in my life that I see someone doing
> 'sizeof' of an 'offsetof' expression. It's not a realistic use of the
> 'offsetof' macro.
Other than to test compliance to other aspects of offsetof.
Are there any other C expressions besides the sizeof operator where
injecting (cast)(expr) will cause a different parse than injecting
((cast)(expr))?
>
> And the workaround is trivial: just add parentheses. It also makes the
> code easier to read:
> sizeof (offsetof (struct d, e))
Then perhaps the simpler patch is to document the bug, but not test for
it, by simply committing test-stddef.c with redundant parenthesis; while
remembering this thread in case we do find other platforms that do have
more severe bugs with using the wrong type.
--
Eric Blake address@hidden +1-801-349-2682
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
[PATCHv2] stddef: fix offsetof compliance, Eric Blake, 2010/08/16