On many systems (esp. BSD ones), building a recent m4 snapshot produces these warnings:
-------------------------------------------------------------------------------- CC regex.o In file included from ../../lib/regex_internal.h:57:0, from ../../lib/regex.c:70: ../../lib/regcomp.c: In function 'rpl_regfree': ../../lib/glthread/lock.h:640:38: warning: statement with no effect [-Wunused-value] # define glthread_lock_destroy(NAME) 0 ^ ../../lib/regex_internal.h:60:26: note: in expansion of macro 'glthread_lock_destroy' # define lock_fini(lock) glthread_lock_destroy (&(lock)) ^ ../../lib/regcomp.c:638:7: note: in expansion of macro 'lock_fini' lock_fini (dfa->lock); ^ ../../lib/regcomp.c: In function 're_compile_internal': ../../lib/glthread/lock.h:640:38: warning: statement with no effect [-Wunused-value] # define glthread_lock_destroy(NAME) 0 ^ ../../lib/regex_internal.h:60:26: note: in expansion of macro 'glthread_lock_destroy' # define lock_fini(lock) glthread_lock_destroy (&(lock)) ^ ../../lib/regcomp.c:781:7: note: in expansion of macro 'lock_fini' lock_fini (dfa->lock); ^ ../../lib/glthread/lock.h:640:38: warning: statement with no effect [-Wunused-value] # define glthread_lock_destroy(NAME) 0 ^ ../../lib/regex_internal.h:60:26: note: in expansion of macro 'glthread_lock_destroy' # define lock_fini(lock) glthread_lock_destroy (&(lock)) ^ ../../lib/regcomp.c:814:7: note: in expansion of macro 'lock_fini' lock_fini (dfa->lock); ^ ../../lib/regexec.c: In function 'rpl_regexec': ../../lib/glthread/lock.h:638:35: warning: statement with no effect [-Wunused-value] # define glthread_lock_lock(NAME) 0 ^ ../../lib/regex_internal.h:61:26: note: in expansion of macro 'glthread_lock_lock' # define lock_lock(lock) glthread_lock_lock (&(lock)) ^ ../../lib/regexec.c:214:3: note: in expansion of macro 'lock_lock' lock_lock (dfa->lock); ^ ../../lib/glthread/lock.h:639:37: warning: statement with no effect [-Wunused-value] # define glthread_lock_unlock(NAME) 0 ^ ../../lib/regex_internal.h:62:28: note: in expansion of macro 'glthread_lock_unlock' # define lock_unlock(lock) glthread_lock_unlock (&(lock)) ^ ../../lib/regexec.c:221:3: note: in expansion of macro 'lock_unlock' lock_unlock (dfa->lock); ^ In file included from ../../lib/regex.c:74:0: ../../lib/regexec.c:198:13: warning: unused variable 'dfa' [-Wunused-variable] re_dfa_t *dfa = preg->buffer; ^ In file included from ../../lib/regex_internal.h:57:0, from ../../lib/regex.c:70: ../../lib/regexec.c: In function 're_search_stub': ../../lib/glthread/lock.h:638:35: warning: statement with no effect [-Wunused-value] # define glthread_lock_lock(NAME) 0 ^ ../../lib/regex_internal.h:61:26: note: in expansion of macro 'glthread_lock_lock' # define lock_lock(lock) glthread_lock_lock (&(lock)) ^ ../../lib/regexec.c:391:3: note: in expansion of macro 'lock_lock' lock_lock (dfa->lock); ^ ../../lib/glthread/lock.h:639:37: warning: statement with no effect [-Wunused-value] # define glthread_lock_unlock(NAME) 0 ^ ../../lib/regex_internal.h:62:28: note: in expansion of macro 'glthread_lock_unlock' # define lock_unlock(lock) glthread_lock_unlock (&(lock)) ^ ../../lib/regexec.c:455:3: note: in expansion of macro 'lock_unlock' lock_unlock (dfa->lock); ^ In file included from ../../lib/regex.c:74:0: ../../lib/regexec.c:378:13: warning: unused variable 'dfa' [-Wunused-variable] re_dfa_t *dfa = bufp->buffer; ^ -------------------------------------------------------------------------------- These warnings are indicating that the regex module is being built for multi- threading, while at the same time the Gnulib 'lock' module is being optimized for single-threading (due to the gl_DISABLE_THREADS invocation in configure.ac). According to the Gnulib documentation section "Optimizations of multithreaded code" several more optimizations can be enabled. This patch - enables these single-threading optimizations, - by doing so, gets rid of the warnings in regex.c, - causes no test failures. OK to push?
>From 611fa6cd92671318b22e70f931db695a58ecdaf3 Mon Sep 17 00:00:00 2001 From: Bruno Haible <br...@clisp.org> Date: Thu, 13 May 2021 10:49:13 +0200 Subject: [PATCH] Enable more single-thread optimizations in gnulib code. * configure.ac (GNULIB_REGEX_SINGLE_THREAD, GNULIB_MBRTOWC_SINGLE_THREAD, GNULIB_WCHAR_SINGLE_LOCALE): Define as C macros. --- configure.ac | 3 +++ 1 file changed, 3 insertions(+) diff --git a/configure.ac b/configure.ac index 04a7d4b..517666f 100644 --- a/configure.ac +++ b/configure.ac @@ -42,6 +42,9 @@ gl_ASSERT_NO_GNULIB_POSIXCHECK # M4 is single-threaded; so we can optimize gnulib code by using this: gl_DISABLE_THREADS +AC_DEFINE([GNULIB_REGEX_SINGLE_THREAD], [1], [Define to optimize regex.]) +AC_DEFINE([GNULIB_MBRTOWC_SINGLE_THREAD], [1], [Define to optimize mbrtowc.]) +AC_DEFINE([GNULIB_WCHAR_SINGLE_LOCALE], [1], [Define to optimize mbrtowc.]) AC_ARG_ENABLE([gcc-warnings], [AS_HELP_STRING([--enable-gcc-warnings], -- 2.7.4