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

From: Peter Rosin <[email-masked]>
Date: Fri, 26 Aug 2016 23:59:44 +0200

On 2016-08-26 20:42, 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. 

Then GNU has abandoned portability. Sad.

> <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.

Feels designed to target 64-bit Windows. Sad.

> (It should be safe to convert ptrdiff_t to long in an LP64 system, so I 
> assume you meant to write "LLP64" in the Subject: line. Also, the values 
> in questions are offsets, not pointers, so I assume you meant to write 
> "pointer differences" not "pointers" in the above-quoted sentence.)

Yes, I fat-fingered the subject and was a bit careless, sorry about
that. Feel free to reword if you end up taking the patch.

> A problem with the proposed patch is that it uses PRIdPTR, and thus 
> won't work on platforms with older C libraries that lack support for 
> PRIdPTR. Although this can be worked around with some effort, as a 
> general rule we prefer to avoid the effort.
> 
> 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

I find these two complaints a little bit contradicting. Do you, or do
you not require c99? Because the POSIX part seems to be connected to
c99, but what do I know?

Besides, I thought the gnulib inttypes module (or whatever it's called)
provided the PRI?PTR macros if missing/broken?

Cheers,
Peter