On 2025-08-07 08:45, Vincent Lefevre wrote:

BTW, I'm wondering whether this test is likely to generate a warning
by future compilers, as AFAIK, incrementing a null pointer is UB.

Yes, let's stop doing that. Thanks for the patches. I installed the attached which I hope fixes this issue in a combined way, and I installed the other one with a minor change to the commit message.
From f3413ffbad65db36cd00be1b15f0c74a59f67af2 Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email protected]>
Date: Thu, 7 Aug 2025 09:03:21 -0700
Subject: [PATCH] Port AC_C_CONST to GCC 16 -Wunused-but-set-variable
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Problem reported by Vincent Lefevre in:
https://lists.gnu.org/r/autoconf-patches/2025-08/msg00001.html
https://lists.gnu.org/r/autoconf-patches/2025-08/msg00002.html
* lib/autoconf/c.m4 (AC_C_CONST): Combine two tests, use
the set variable, and don’t try to add 1 to a null pointer.
---
 lib/autoconf/c.m4 | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/lib/autoconf/c.m4 b/lib/autoconf/c.m4
index bafa72c1..12c9a5c5 100644
--- a/lib/autoconf/c.m4
+++ b/lib/autoconf/c.m4
@@ -2137,15 +2137,12 @@ AC_DEFUN([AC_C_CONST],
     *t++ = 0;
     if (s) return 0;
   }
-  { /* Someone thinks the Sun supposedly-ANSI compiler will reject this.  */
+  { /* Derived from code rejected by Sun C 1.0 and similar vintage.  */
     int x[] = {25, 17};
-    const int *foo = &x[0];
+    typedef int const *iptr;
+    iptr foo = &x[0];
     ++foo;
-  }
-  { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
-    typedef const int *iptr;
-    iptr p = 0;
-    ++p;
+    if (!*foo) return 0;
   }
   { /* IBM XL C 1.02.0.0 rejects this sort of thing, saying
        "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
-- 
2.48.1

Reply via email to