From: Paul Eggert Date: Thu, 7 Aug 2025 16:03:21 +0000 (-0700) Subject: Port AC_C_CONST to GCC 16 -Wunused-but-set-variable X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6fc6066df1b8902ba255c007e87c084fead75119;p=thirdparty%2Fautoconf.git Port AC_C_CONST to GCC 16 -Wunused-but-set-variable 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. --- diff --git a/lib/autoconf/c.m4 b/lib/autoconf/c.m4 index bafa72c1c..12c9a5c51 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. */