Hi,
The CI job [1] currently fails in the "make distcheck" step. I can reproduce it
on an Ubuntu 16.04.x machine:
$ ./configure --config-cache --enable-gcc-warnings CPPFLAGS="-Wall"
...
$ make V=1
...
gcc -I../lib -I../lib -Wall -fno-common -Wall -Wbad-function-cast
-Wdate-time -Wdisabled-optimization -Wdouble-promotion -Wextra
-Wformat-signedness -Winit-self -Winline -Winvalid-pch -Wlogical-op
-Wmissing-declarations -Wmissing-include-dirs -Wmissing-prototypes
-Wnested-externs -Wold-style-definition -Wopenmp-simd -Woverlength-strings
-Wpacked -Wpointer-arith -Wshadow -Wstack-protector -Wstrict-overflow
-Wstrict-prototypes -Wsuggest-attribute=const -Wsuggest-attribute=format
-Wsuggest-attribute=noreturn -Wsuggest-attribute=pure -Wsuggest-final-methods
-Wsuggest-final-types -Wsync-nand -Wtrampolines -Wuninitialized
-Wunknown-pragmas -Wunsafe-loop-optimizations -Wunused-macros -Wvariadic-macros
-Wvector-operation-performance -Wvla -Wwrite-strings -Warray-bounds=2
-Wformat=2 -Werror -g -O2 -MT m4.o -MD -MP -MF $depbase.Tpo -c -o m4.o m4.c &&\
mv -f $depbase.Tpo $depbase.Po
m4.c:166:1: error: function might be candidate for attribute 'pure' if it is
known to return normally [-Werror=suggest-attribute=pure]
fault_handler (int signo)
^
cc1: all warnings being treated as errors
make[2]: *** [Makefile:1875: m4.o] Error 1
The --enable-gcc-warnings option is not enabled by default, but it gets enabled
for "make distcheck" through Makefile.am:
DISTCHECK_CONFIGURE_FLAGS = --enable-changeword --program-prefix=g \
--enable-gcc-warnings --enable-silent-rules --enable-cxx
It is not clear to me whether the function 'fault_handler' should be
marked with attribute 'pure' or not. One one hand, it fits the description
from [2] (namely, that repeated calls to the function perform the same
effects as a single call - because the function does nothing if it does
not call _exit()). On the other hand, [2] also says "a pure function cannot have
any observable side effects" - but 'fault_handler' calls write() and _exit(),
which are side effects.
I would therefore suggest to eliminate this -Werror=suggest-attribute=pure
warning.
The attached patch achieves this.
Bruno
[1]
https://storage.googleapis.com/gitlab-gprd-artifacts/3f/e0/3fe0bab108039f3fd0087d91599c91c1264be96bca03cb2d222220506e93f0ef/2020_07_11/634130389/696039236/job.log?response-content-type=text%2Fplain%3B%20charset%3Dutf-8&response-content-disposition=inline&GoogleAccessId=gitlab-object-storage-...@gitlab-production.iam.gserviceaccount.com&Signature=yx5rXmQKTx%2Ff%2FmD2MoQ6PeBV7JBXHvu%2FHp817gM5YO3VjMt9l5bA%2B8%2FYXIrz%0AZWtkq4h2v0fQdRuzcjXOaScbHjcoBoI%2BwFC7l248Ds5nxSM0QCheiM8AF1Gt%0AJA1A6UEZDs1nfgjGB463auPhV8DD5fdpoO0owCe%2BVyucUGoINgfyroTSDzm0%0ALHrelt%2FVveBb3%2FITqF5zkVyW1vCtT68ZcSRqG8FQaKe8Cs6Up%2BzAFiSvGKMx%0AQ9YgLEBJ0wrMqBUdYDDB2ErsqxUgVoyDu2bJ1IwqRMA045p9vQZ%2FxqDVEzIE%0AOzCMU3UR27JDI1O7jJWpFJCy6iKtkn43GH%2FQFVN9RA%3D%3D&Expires=1594464650
[2]
https://gcc.gnu.org/onlinedocs/gcc-10.1.0/gcc/Common-Function-Attributes.html
>From dd0238c24a64fdbb35fe6fd2310425d5a07f38e6 Mon Sep 17 00:00:00 2001
From: Bruno Haible <[email protected]>
Date: Sat, 11 Jul 2020 13:12:59 +0200
Subject: [PATCH] Fix "make distcheck" failure on Ubuntu 16.04.
* configure.ac: Don't use the warning option -Wsuggest-attribute=pure.
---
configure.ac | 3 +++
1 file changed, 3 insertions(+)
diff --git a/configure.ac b/configure.ac
index b248493..d2962bf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -91,6 +91,9 @@ if test "$gl_gcc_warnings" = yes; then
nw="$nw -Wswitch-enum" # Too many warnings for now
# gcc 4.4.6 complains enum-compare is C++ only; gcc 4.7.0 implies it in -Wall
nw="$nw -Wenum-compare"
+ # gcc 5.4.0 suggests to mark 'fault_handler' with attribute 'pure', although
+ # this function has side effects.
+ nw="$nw -Wsuggest-attribute=pure"
# Gnulib uses '#pragma GCC diagnostic push' to silence some
# warnings, but older gcc doesn't support this.
--
2.7.4