[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: test-getgroups.c:stringop-overflow warning on newer GCC
From: |
Bruno Haible |
Subject: |
Re: test-getgroups.c:stringop-overflow warning on newer GCC |
Date: |
Fri, 01 Jan 2021 13:56:53 +0100 |
User-agent: |
KMail/5.1.3 (Linux/4.4.0-197-generic; KDE/5.18.0; x86_64; ; ) |
Hi Berny,
Bernhard Voelker wrote in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-12/msg00090.html>:
> Newer GCC complains about this test:
>
> $ make test-getgroups.o V=1
> depbase=`echo test-getgroups.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
> gcc -DHAVE_CONFIG_H -DEXEEXT=\"\" -I. -I.. -DIN_FINDUTILS_GNULIB_TESTS=1
> -I. -I. -I.. -I./.. -I../gl/lib -I./.. \
> /gl/lib -g -O2 -MT test-getgroups.o -MD -MP -MF $depbase.Tpo -c -o
> test-getgroups.o test-getgroups.c &&\
> mv -f $depbase.Tpo $depbase.Po
> In file included from test-getgroups.c:31:
> test-getgroups.c: In function 'main':
> test-getgroups.c:65:11: warning: argument 1 value -1 is negative
> [-Wstringop-overflow=]
> 65 | ASSERT (getgroups (-1, NULL) == -1);
> | ^~~~~~~~~~~~~~~~~~~~
I can't reproduce this with a testdir created through
./gnulib-tool --create-testdir --dir=... --single-configure getgroups
and GCC 10.2.0, even with '-Wall' (whereas the GCC invocation that you show does
not invoke any warning options!):
$ gcc -DHAVE_CONFIG_H -I. -I.. -DGNULIB_STRICT_CHECKING=1 -DIN_GNULIB_TESTS=1
-I. -I. -I.. -I./.. -I../gllib -I./../gllib -g -O2 -c test-getgroups.c -Wall
(no diagnostics)
Also, it's strange that this warning reports to come from -Wstringop-overflow
— whereas 'getgroups' is not a string operation.
So, to me it looks like a bug in the particular GCC version that you are using.
Under regular circumstances, I would consider adding a #pragma GCC diagnostic,
as you suggest, but not under these circumstances.
Bruno
- Re: test-getgroups.c:stringop-overflow warning on newer GCC,
Bruno Haible <=