[PATCH] diffseq: pacify gcc -Wusless-cast

Paul Eggert <[email protected]>
Newsgroups gmane.comp.lib.gnulib.bugs
Message-ID <[email protected]>
* lib/diffseq.h (OFFSET_MAX): Pacify when OFFSET is int.
---
 ChangeLog     | 5 +++++
 lib/diffseq.h | 5 +++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 0611c6c7a1..80bca2cba3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2026-05-25  Paul Eggert  <[email protected]>
+
+	diffseq: pacify gcc -Wusless-cast
+	* lib/diffseq.h (OFFSET_MAX): Pacify when OFFSET is int.
+
 2026-05-25  Bruno Haible  <[email protected]>
 
 	trim tests: Enhance tests.
diff --git a/lib/diffseq.h b/lib/diffseq.h
index cf710a316f..73fa47b42e 100644
--- a/lib/diffseq.h
+++ b/lib/diffseq.h
@@ -82,10 +82,11 @@
  #error "Please include config.h first."
 #endif
 
-/* Maximum value of type OFFSET.  */
+/* Maximum value of type OFFSET.  The 1u pacifies -Wuseless-cast, and
+   unlike a compound literal can appear in an integer constant expression.  */
 #ifndef OFFSET_MAX
 # define OFFSET_MAX \
-   ((((OFFSET) 1 << (sizeof (OFFSET) * CHAR_BIT - 2)) - 1) * 2 + 1)
+   ((((OFFSET) 1u << (sizeof (OFFSET) * CHAR_BIT - 2)) - 1) * 2 + 1)
 #endif
 
 /* Default to no early abort.  */
-- 
2.54.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.