On 2026-01-16 03:47, Pádraig Brady wrote:
cc1: error: command-line option '-Wzero-as-null-pointer-constant'
is valid for C++/ObjC++ but not for C [-Werror]
That's because the option is accepted, but always gives a warning.
I wonder should the gnulib manywarnings compat checking
always have -Werror enabled to auto remove such options
from use on unsupporting compilers?
That might be one way to go, though you'd need to test whether -Werror
works I suppose. I took a simpler way out, by looking at the GCC version
(which this code already does for other reasons) in the attached. This
patch also ports to Ubuntu GCC.
The implication of that is, the sc_prohibit_NULL syntax check will fail.
I'll probably remove the syntax check anyway,
and possibly s/nullptr/NULL/ everywhere for consistency.
Both sound good to me, thanks.
From 73e6357e410c70a12ebedac4fc9d48f97e2c0ad4 Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email protected]>
Date: Fri, 16 Jan 2026 12:26:22 -0800
Subject: [PATCH] manywarnings: omit new C warning for GCC < 15
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Problem reported by Pádraig Brady in:
https://lists.gnu.org/r/bug-gnulib/2026-01/msg00135.html
* m4/manywarnings.m4 (gl_MANYWARN_ALL_GCC(C)):
Do not add -Wzero-as-null-pointer-constant for GCC < 15.
Also, accept strings like "gcc-14 (Ubuntu 14.3.0-8ubuntu1) 14.3.0"
as specifying GCC versions like 14.3.0.
---
ChangeLog | 8 ++++++++
m4/manywarnings.m4 | 20 ++++++++++++++------
2 files changed, 22 insertions(+), 6 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index bd77658a74..c880440831 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2026-01-16 Paul Eggert <[email protected]>
+ manywarnings: omit new C warning for GCC < 15
+ Problem reported by Pádraig Brady in:
+ https://lists.gnu.org/r/bug-gnulib/2026-01/msg00135.html
+ * m4/manywarnings.m4 (gl_MANYWARN_ALL_GCC(C)):
+ Do not add -Wzero-as-null-pointer-constant for GCC < 15.
+ Also, accept strings like "gcc-14 (Ubuntu 14.3.0-8ubuntu1) 14.3.0"
+ as specifying GCC versions like 14.3.0.
+
selinux-h: pacify -Wzero-as-null-pointer-constant
* lib/se-context.in.h (context_t): Make it a pointer to an
incomplete type rather than an int, so that callers can initialize
diff --git a/m4/manywarnings.m4 b/m4/manywarnings.m4
index 97567b2530..4cb17a689a 100644
--- a/m4/manywarnings.m4
+++ b/m4/manywarnings.m4
@@ -1,5 +1,5 @@
# manywarnings.m4
-# serial 30
+# serial 31
dnl Copyright (C) 2008-2026 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -150,7 +150,6 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC(C)],
-Wvector-operation-performance \
-Wvla \
-Wwrite-strings \
- -Wzero-as-null-pointer-constant \
; do
AS_VAR_APPEND([$1], [" $gl_manywarn_item"])
done
@@ -169,20 +168,29 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC(C)],
AS_VAR_APPEND([$1], [' -Wunused-const-variable=2'])
AS_VAR_APPEND([$1], [' -Wvla-larger-than=4031'])
- # These are needed for older GCC versions.
+ # These depend on the GCC version.
if test -n "$GCC" && gl_gcc_version=`($CC --version) 2>/dev/null`; then
case $gl_gcc_version in
- 'gcc (GCC) '[[0-3]].* | \
- 'gcc (GCC) '4.[[0-7]].*)
+ gcc*' ('*') '[[0-3]].* | \
+ gcc*' ('*') '4.[[0-7]].*)
AS_VAR_APPEND([$1], [' -fdiagnostics-show-option'])
AS_VAR_APPEND([$1], [' -funit-at-a-time'])
;;
esac
case $gl_gcc_version in
- 'gcc (GCC) '[[0-9]].*)
+ gcc*' ('*') '[[0-9]].*)
AS_VAR_APPEND([$1], [' -fno-common'])
;;
esac
+ case $gl_gcc_version in
+ gcc*' ('*') '?.* | gcc*' ('*') '1[[1-4]].*)
+ # In GCC < 15 the option either does not exist,
+ # or is accepted but always warns.
+ ;;
+ *)
+ AS_VAR_APPEND([$1], [' -Wzero-as-null-pointer-constant'])
+ ;;
+ esac
fi
# These options are not supported by gcc, but are useful with clang.
--
2.51.0