On 11/28/2011 04:39 PM, Bruno Haible wrote: > Hi Matthew, > >> e->short_options += (short_options - hol->short_options); >> >> subtracts two pointers that do not point to the same memory object. >> Something like: >> >> e->short_options = short_options + (e->short_options - hol->short_options); >> >> does the intended operation with legal pointer arithmetic. > > Thanks for the suggestion. > > However, I find the existing code easier to understand than the one you > propose. Therefore, to understand the possible impact, a question: > > Do you know of any platforms where sizeof (ptrdiff_t) < sizeof (void *) ?
In current practice, no, I don't. But in theory, it is possible to have a 64-bit void* but only a 32-bit ptrdiff_t, on a platform where the maximum compiled object is only 4GiB (since ptrdiff_t need only represent the difference between offsets within an object, and not a full pointer). And as an actual example, in the old days of x86 segment programming (thankfully now long gone), it was possible to have 32-bit pointers but only 16-bit ptrdiff_t to represent the max size of an object that resides in the current segment overlay. http://lkml.indiana.edu/hypermail/linux/kernel/9902.2/0238.html -- Eric Blake ebl...@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature