[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
test-getgroups.c:stringop-overflow warning on newer GCC
From: |
Bernhard Voelker |
Subject: |
test-getgroups.c:stringop-overflow warning on newer GCC |
Date: |
Tue, 8 Dec 2020 23:57:02 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 |
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);
| ^~~~~~~~~~~~~~~~~~~~
macros.h:57:13: note: in definition of macro 'ASSERT'
57 | if (!(expr))
\
| ^~~~
In file included from ../gl/lib/unistd.h:40,
from test-getgroups.c:21:
/usr/include/unistd.h:701:12: note: in a call to function 'getgroups'
declared with attribute 'write_only (2, 1)'
701 | extern int getgroups (int __size, __gid_t __list[]) __THROW __wur
| ^~~~~~~~~
This is the whole declaration from the system's unistd.h:
$ sed -n 698,702p /usr/include/unistd.h
/* If SIZE is zero, return the number of supplementary groups
the calling process is in. Otherwise, fill in the group IDs
of its supplementary groups in LIST and return the number written. */
extern int getgroups (int __size, __gid_t __list[]) __THROW __wur
__attr_access ((__write_only__, 2, 1));
I could reproduce on openSUSE:Tumbleweed and Fedora 33,
both having GCC-10.2.1:
$ gcc --version | sed 1q
gcc (SUSE Linux) 10.2.1 20201117 [revision
98ba03ffe0b9f37b4916ce6238fad754e00d720b]
$ gcc --version | sed 1q
gcc (GCC) 10.2.1 20201125 (Red Hat 10.2.1-9)
Well, the test is explicitly testing the behavior when passing a negative
number.
Maybe we should add this to the test?
# pragma GCC diagnostic ignored "-Wstringop-overflow"
Thanks & have a nice day,
Berny
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- test-getgroups.c:stringop-overflow warning on newer GCC,
Bernhard Voelker <=