Subject: bug#43666: [grep-3.5] make failed on Solaris 11.3 x86/x64

From: Kiyoshi KANAZAWA <[email-masked]>
Date: Wed, 30 Sep 2020 07:47:49 +0900 (JST)

Hello,

I'm watching bug-gnulib.
It is strange that only i386 has the problem, but amd64 do not.

FYI.
When building autogen-5.19.96 on Solaris 11.3 x86/x64, make error is detected only with i386.
With amd64 (CC='gcc -m64') make & make check passes.

$ ./configure CC=gcc
$ make
  :
/bin/sh ../libtool  --tag=CC   --mode=compile gcc -O2 -m32 -DHAVE_CONFIG_H -I. -I..  -I.. -I../autoopts  -DPKGDATADIR='"/opt/local/share/autogen"' -Wno-format-contains-nul -fno-strict-aliasing -Wall -Werror -Wcast-align -Wmissing-prototypes -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings -Wstrict-aliasing=3 -Wextra -Wno-cast-qual -Wno-format-contains-nul -fno-strict-aliasing -c -o libopts_la-libopts.lo `test -f 'libopts.c' || echo './'`libopts.c
libtool: compile:  gcc -O2 -m32 -DHAVE_CONFIG_H -I. -I.. -I.. -I../autoopts "-DPKGDATADIR=\"/opt/local/share/autogen\"" -Wno-format-contains-nul -fno-strict-aliasing -Wall -Werror -Wcast-align -Wmissing-prototypes -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings -Wstrict-aliasing=3 -Wextra -Wno-cast-qual -Wno-format-contains-nul -fno-strict-aliasing -c libopts.c  -fPIC -DPIC -o .libs/libopts_la-libopts.o
In file included from libopts.c:57:
usage.c: In function 'prt_extd_usage':
usage.c:736:38: error: 's ' directive output may be truncated writing 2 bytes into a region of size between 0 and 9 [-Werror=format-truncation=]
  736 |         snprintf(vfmt, sizeof(vfmt), vfmtfmt, (unsigned int)nmlen + 4);
      |                                      ^~~~~~~
usage.c:736:9: note: 'snprintf' output between 9 and 18 bytes into a destination of size 12
  736 |         snprintf(vfmt, sizeof(vfmt), vfmtfmt, (unsigned int)nmlen + 4);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[4]: *** [Makefile:1081: libopts_la-libopts.lo] Error 1
make[4]: Leaving directory '/tmp/autogen-5.19.96/autoopts'
make[3]: *** [Makefile:1311: all-recursive] Error 1
make[3]: Leaving directory '/tmp/autogen-5.19.96/autoopts'
make[2]: *** [Makefile:930: all] Error 2
make[2]: Leaving directory '/tmp/autogen-5.19.96/autoopts'
make[1]: *** [Makefile:857: all-recursive] Error 1
make[1]: Leaving directory '/tmp/autogen-5.19.96'
make: *** [Makefile:764: all] Error 2

To avoid this, I have to kill -Werror option with the following patch.
I'm afraid that this is not a correct way.

diff -ur ../autogen-5.19.96.orig/configure.ac ./configure.ac
--- ../autogen-5.19.96.orig/configure.ac        2020-09-28 04:45:31.000000000 +0000
+++ ./configure.ac      2020-09-30 07:35:55.837238555 +0000
@@ -197,7 +197,7 @@
 WARN_CFLAGS=
 test "X${GCC}" = Xyes && {
   CFLAGS="$CFLAGS -Wno-format-contains-nul -fno-strict-aliasing"
-  WARN_CFLAGS="$CFLAGS "`echo -Wall -Werror -Wcast-align -Wmissing-prototypes \
+  WARN_CFLAGS="$CFLAGS "`echo -Wall -Wcast-align -Wmissing-prototypes \
        -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings \
        -Wstrict-aliasing=3 -Wextra -Wno-cast-qual`
 }]dnl -Wconversion -Wsign-conversion -Wstrict-overflow

Regards,

--- Kiyoshi