Subject: bug#24311: [bug-diffutils] bug#24311: bug#24311: [PATCH] maint: accommodate LP64 systems

From: Eric Blake <[email-masked]>
Date: Fri, 26 Aug 2016 14:40:57 -0500

On 08/26/2016 01:42 PM, Paul Eggert wrote:
> On 08/26/2016 01:41 AM, Peter Rosin wrote:
>> It is wrong to assume that pointers fit in long int.
> 
> Not in GNU code.
> <https://www.gnu.org/prep/standards/html_node/CPU-Portability.html says
> that GNU programs should not make any effort to cater to the possibility
> that 'long' will be narrower than ptrdiff_t.
> 

Except that the mingw64 platform is indeed a modern platform where
pointers are 8 bytes but long is 4 bytes.  So maybe it is time to
propose a patch to the GNU Coding Standards that document the reality of
existing systems, and then start the process of auditing which programs
have been relying on the assumptions now rendered untrue by catering to
such a platform.

> Every POSIX platform is supposed to provide a compilation environment
> where 'long' is no wider than ptrdiff_t, so if you're using a POSIX
> platform you should be able to build diffutils without modifying its
> source code. See:
> 
> http://pubs.opengroup.org/onlinepubs/9699919799/utilities/c99.html
> 

But GNU software often tries to be portable to more than just POSIX
platforms, and gnulib is already useful for catering to mingw64 where we
indeed have long narrower than intptr_t (I'm not sure off-hand whether
intptr_t and ptrdiff_t are the same size, or if ptrdiff_t is only 4 bytes).

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org