Paul Eggert wrote:
> However, in this case pacifying Clang saved a byte and made the code a 
> bit clearer by omitting an unnecessary and possibly-confusing 
> terminating null, so it's arguably a win anyway.

Granted, the patch to nstrftime.c was correct. But since you also say:

> Yes, it's a bogus warning that attempts to impose a C++ style onto C. 

I would rather eliminate all future occurrences of this warning as well.

> Admittedly the patch also meant I didn't have to change the Emacs 
> configure script to add -Wno-string-plus-int to CFLAGS. Perhaps we 
> should change Gnulib's manywarnings module to specify 
> -Wno-string-plus-int automatically when compiling Gnulib code with a 
> clang that supports that option; then these sorts of complaints wouldn't 
> come up as often.

We need to distinguish two things:

  * Silencing a warning in Gnulib code, once imported into a package via
    gnulib-tool.
    This is done in m4/gnulib-common.m4.

  * Silencing a warning in the code of packages that use the 'manywarnings'
    module.
    This is done in m4/manywarnings.m4.

Neither have an effect on gnulib testdirs; we can live with that.

This patch eliminates the warning from Gnulib code.


2026-03-02  Bruno Haible  <[email protected]>

        Silence clang's -Wstring-plus-int warnings in Gnulib code.
        * m4/gnulib-common.m4 (gl_CC_GNULIB_WARNINGS): Add -Wno-string-plus-int.

diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4
index 26eef771db..8fba00da27 100644
--- a/m4/gnulib-common.m4
+++ b/m4/gnulib-common.m4
@@ -1,5 +1,5 @@
 # gnulib-common.m4
-# serial 115
+# serial 116
 dnl Copyright (C) 2007-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,
@@ -1425,6 +1425,7 @@ AC_DEFUN([gl_CC_GNULIB_WARNINGS]
     dnl -Wno-pedantic                         >= 4.8          >= 3.9
     dnl -Wno-sign-compare                     >= 3            >= 3.9
     dnl -Wno-sign-conversion                  >= 4.3          >= 3.9
+    dnl -Wno-string-plus-int                  -               >= 3.9
     dnl -Wno-tautological-out-of-range-compare  -             >= 3.9
     dnl -Wno-type-limits                      >= 4.3          >= 3.9
     dnl -Wno-undef                            >= 3            >= 3.9
@@ -1453,6 +1454,7 @@ AC_DEFUN([gl_CC_GNULIB_WARNINGS]
       -Wno-pedantic
       #endif
       #if 3 < __clang_major__ + (9 <= __clang_minor__)
+      -Wno-string-plus-int
       -Wno-tautological-constant-out-of-range-compare
       #endif
       #if (__GNUC__ + (__GNUC_MINOR__ >= 3) > 4 && !defined __clang__) || 
(__clang_major__ + (__clang_minor__ >= 9) > 3)




Reply via email to