Subject: Re: bug#63632: diffutils 3.10: test suite is failing in test-strtoll unit

From: Paul Eggert <[email-masked]>
Date: Sun, 21 May 2023 18:36:51 -0700

On 2023-05-21 14:50, Tomasz Kłoczko wrote:
> test-strtoll.c:290: assertion 'ptr == input + 1' failed

I don't have that problem when I run the tests on Fedora 38 x86-64. What 
platform are you using, and how did you configure it?

I do see a potential on the Gnulib side, which I attempted to fix by 
installing the attached (and I'll cc bug-gnulib).

This is a Gnulib issue not a diffutils issue per se, so I wouldn't worry 
about it as far as diffutils go.

From 3ad52f3e21db96096105256ff66ebf480703a09f Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email-masked]>
Date: Sun, 21 May 2023 18:25:45 -0700
Subject: [PATCH] strtol: match 'configure' to 'make check'
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Inferred from report by Tomasz Kłoczko <https://bugs.gnu.org/63632>.
* m4/strtol.m4 (gl_FUNC_STRTOL):
* m4/strtoll.m4 (gl_FUNC_STRTOLL):
Also test "0b", since the test cases check it.
---
 ChangeLog     |  6 ++++++
 m4/strtol.m4  | 16 +++++++++++-----
 m4/strtoll.m4 | 16 +++++++++++-----
 3 files changed, 28 insertions(+), 10 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 8b29eed568..37eb0a06c6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2023-05-21  Paul Eggert  <[email-masked]>
 
+	strtol: match 'configure' to 'make check'
+	Inferred from report by Tomasz Kłoczko <https://bugs.gnu.org/63632>.
+	* m4/strtol.m4 (gl_FUNC_STRTOL):
+	* m4/strtoll.m4 (gl_FUNC_STRTOLL):
+	Also test "0b", since the test cases check it.
+
 	git-merge-changelog: port to size_t padding
 	* lib/git-merge-changelog (entry_hashcode):
 	As a nicety, Prefer SIZE_WIDTH to computing it ourselves.
diff --git a/m4/strtol.m4 b/m4/strtol.m4
index 5cdd86adc7..b5ea56f229 100644
--- a/m4/strtol.m4
+++ b/m4/strtol.m4
@@ -1,4 +1,4 @@
-# strtol.m4 serial 8
+# strtol.m4 serial 9
 dnl Copyright (C) 2002-2003, 2006, 2009-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -19,10 +19,16 @@ AC_DEFUN([gl_FUNC_STRTOL],
               char *term;
               /* This test fails on Minix and native Windows.  */
               {
-                const char input[] = "0x";
-                (void) strtol (input, &term, 16);
-                if (term != input + 1)
-                  result |= 1;
+                static char const input[2][3] = {"0x", "0b"};
+                static int const base[] = {0, 2, 10};
+                int i, j;
+                for (i = 0; i < 2; i++)
+                  for (j = 0; j < 3; j++)
+                    {
+                      (void) strtol (input[i], &term, base[j]);
+                      if (term != input[i] + 1)
+                        result |= 1;
+                    }
               }
               /* This test fails on pre-C23 platforms.  */
               {
diff --git a/m4/strtoll.m4 b/m4/strtoll.m4
index ec09609cd4..a0cbc805bc 100644
--- a/m4/strtoll.m4
+++ b/m4/strtoll.m4
@@ -1,4 +1,4 @@
-# strtoll.m4 serial 10
+# strtoll.m4 serial 11
 dnl Copyright (C) 2002, 2004, 2006, 2008-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -19,10 +19,16 @@ AC_DEFUN([gl_FUNC_STRTOLL],
               char *term;
               /* This test fails on Minix and native Windows.  */
               {
-                const char input[] = "0x";
-                (void) strtoll (input, &term, 16);
-                if (term != input + 1)
-                  result |= 1;
+                static char const input[2][3] = {"0x", "0b"};
+                static int const base[] = {0, 2, 10};
+                int i, j;
+                for (i = 0; i < 2; i++)
+                  for (j = 0; j < 3; j++)
+                    {
+                      (void) strtoll (input[i], &term, base[j]);
+                      if (term != input[i] + 1)
+                        result |= 1;
+                    }
               }
               /* This test fails on pre-C23 platforms.  */
               {
-- 
2.39.2