Peter Rosin wrote:

better patch might be a configure check to see
if %td works, with machinery to set printint/pI to ptrdiff_t/"t" if it does and
fall back to long int/"l" if it doesn't.

That'd be more work to develop and would be more likely to go wrong and would slow down 'configure'. I installed the attached patch instead.

My main beef with the GCS on this issue is that it suggests that maintainers
should not spend any time at all on this issue, as if that would be contrary
to some other goal.

It sucks away resources that could be used to support more-important goals. We've already spent more time on Bug#24311 than the problem was worth. Maintainers should not expend any significant time going down this rabbit hole.
From 92f3cb47aebf576987c97744028f1775c5518cf0 Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email protected]>
Date: Sun, 28 Aug 2016 16:46:34 -0700
Subject: [PATCH] diff: don't assume ptrdiff_t <= long long int

* src/system.h (printint, pI): Port to (theoretical) platforms
where ptrdiff_t is wider than long long int (Bug#24311).
---
 src/system.h | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/system.h b/src/system.h
index 481d3a0..028113e 100644
--- a/src/system.h
+++ b/src/system.h
@@ -134,17 +134,19 @@ typedef ptrdiff_t lin;
 #define LIN_MAX PTRDIFF_MAX
 
 /* The signed integer type for printing line numbers, and its printf
-   length modifier.  Prefer 'long int' if it suffices, to cater to C
-   implementations that lack support for "ll".  The natural
-   C99-or-later implementation with ptrdiff_t and "t" is less portable
-   in practice.  */
+   length modifier.  This is not simply ptrdiff_t, to cater to older
+   and/or nonstandard C libraries where "l" works but "ll" and "t" do
+   not, or where 'long' is too narrow and "ll" works but "t" does not.  */
 
 #if LIN_MAX <= LONG_MAX
 typedef long int printint;
 # define pI "l"
-#else
+#elif LIN_MAX <= LLONG_MAX
 typedef long long int printint;
 # define pI "ll"
+#else
+typedef ptrdiff_t printint;
+# define pI "t"
 #endif
 
 verify (TYPE_SIGNED (lin));
-- 
2.7.4

Reply via email to