I pushed the attached patch to silence this warning:
$ gnulib-tool --create-testdir --dir testdir1 regex
$ cd testdir1
$ ./configure CFLAGS='-Wzero-as-null-pointer-constant'
$ make
[...]
gcc -DHAVE_CONFIG_H -I. -I.. -DGNULIB_STRICT_CHECKING=1
-Wzero-as-null-pointer-constant -MT regex.o -MD -MP -MF $depbase.Tpo -c -o
regex.o regex.c &&\
mv -f $depbase.Tpo $depbase.Po
In file included from regex.c:72:
regexec.c: In function ‘merge_state_with_log’:
regexec.c:2344:40: warning: zero as null pointer constant
[-Wzero-as-null-pointer-constant]
2344 | else if (mctx->state_log[cur_idx] == 0)
|
[...]
The 'git blame' shows the code is many years old. I just only noticed it
now since we began replacing glibc's regex.
Collin
>From b6e096af3876e0e4093c0c885abe311a7cb9c3e5 Mon Sep 17 00:00:00 2001
Message-ID: <b6e096af3876e0e4093c0c885abe311a7cb9c3e5.1776401903.git.collin.fu...@gmail.com>
From: Collin Funk <[email protected]>
Date: Thu, 16 Apr 2026 21:50:27 -0700
Subject: [PATCH] regex: Silence -Wzero-as-null-pointer-constant warning.
* lib/regexec.c (merge_state_with_log): Check the pointer against NULL.
---
ChangeLog | 5 +++++
lib/regexec.c | 2 +-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index 59b4906765..39529954bc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2026-04-16 Collin Funk <[email protected]>
+
+ regex: Silence -Wzero-as-null-pointer-constant warning.
+ * lib/regexec.c (merge_state_with_log): Check the pointer against NULL.
+
2026-04-16 Bruno Haible <[email protected]>
byteswap: Fix compilation on Solaris OpenIndiana (regr. 2026-03-20).
diff --git a/lib/regexec.c b/lib/regexec.c
index 65d4d0f09e..ff62ac08ef 100644
--- a/lib/regexec.c
+++ b/lib/regexec.c
@@ -2341,7 +2341,7 @@ merge_state_with_log (reg_errcode_t *err, re_match_context_t *mctx,
mctx->state_log[cur_idx] = next_state;
mctx->state_log_top = cur_idx;
}
- else if (mctx->state_log[cur_idx] == 0)
+ else if (mctx->state_log[cur_idx] == NULL)
{
mctx->state_log[cur_idx] = next_state;
}
--
2.53.0