Avoid array-bounds warning in testsuite on i586
Commit Message
gcc-6 is complaining about this, breaking the testsuite run:
In file included from ../string/string.h:627:0,
from ../include/string.h:54,
from tester.c:32,
from inl-tester.c:6:
tester.c: In function 'test_strncat':
../sysdeps/x86/bits/string.h:1092:3: error: array subscript is below array bounds [-Werror=array-bounds]
--__tmp;
^~~~~~~
I don't see any other way to avoid the warning.
Andreas.
[BZ #20260]
* sysdeps/i386/Makefile (CFLAGS-inl-tester.c): Define.
* string/Makefile (CFLAGS-inl-tester.c, CFLAGS-noinl-tester.c)
(CFLAGS-tst-strlen.c, CFLAGS-stratcliff.c, CFLAGS-test-ffs.c)
(CFLAGS-tst-inlcall.c): Append value.
---
string/Makefile | 12 ++++++------
sysdeps/i386/Makefile | 4 ++++
2 files changed, 10 insertions(+), 6 deletions(-)
Comments
On 06/29/2016 11:08 AM, Andreas Schwab wrote:
> gcc-6 is complaining about this, breaking the testsuite run:
>
> In file included from ../string/string.h:627:0,
> from ../include/string.h:54,
> from tester.c:32,
> from inl-tester.c:6:
> tester.c: In function 'test_strncat':
> ../sysdeps/x86/bits/string.h:1092:3: error: array subscript is below array bounds [-Werror=array-bounds]
> --__tmp;
> ^~~~~~~
>
> I don't see any other way to avoid the warning.
We could move the decrement operation into the assembly part, where GCC
cannot see it. Or we could cast to uintptr_t before subtracting 1.
> +# Suppress array bounds warning from strncat macro in
> +# sysdeps/x86/bits/string.h when building for i[345]86
> +CFLAGS-inl-tester.c += -Wno-array-bounds
It's triggered by an installed header, so this does not fix the bug at
all. I expect applications run into the warning as well.
Thanks,
Florian
Florian Weimer <fweimer@redhat.com> writes:
> It's triggered by an installed header, so this does not fix the bug at
> all. I expect applications run into the warning as well.
Only if compiled with -Wsystem-headers.
Andreas.
On 06/29/2016 01:58 PM, Andreas Schwab wrote:
> Florian Weimer <fweimer@redhat.com> writes:
>
>> It's triggered by an installed header, so this does not fix the bug at
>> all. I expect applications run into the warning as well.
>
> Only if compiled with -Wsystem-headers.
I would expect that this could trip ubsan as well.
Florian
@@ -64,12 +64,12 @@ endif
include ../Rules
-CFLAGS-inl-tester.c = -fno-builtin
-CFLAGS-noinl-tester.c = -fno-builtin
-CFLAGS-tst-strlen.c = -fno-builtin
-CFLAGS-stratcliff.c = -fno-builtin
-CFLAGS-test-ffs.c = -fno-builtin
-CFLAGS-tst-inlcall.c = -fno-builtin
+CFLAGS-inl-tester.c += -fno-builtin
+CFLAGS-noinl-tester.c += -fno-builtin
+CFLAGS-tst-strlen.c += -fno-builtin
+CFLAGS-stratcliff.c += -fno-builtin
+CFLAGS-test-ffs.c += -fno-builtin
+CFLAGS-tst-inlcall.c += -fno-builtin
ifeq ($(run-built-tests),yes)
$(objpfx)tst-svc-cmp.out: tst-svc.expect $(objpfx)tst-svc.out
@@ -7,6 +7,10 @@ long-double-fcts = yes
ifeq ($(subdir),string)
sysdep_routines += cacheinfo
+
+# Suppress array bounds warning from strncat macro in
+# sysdeps/x86/bits/string.h when building for i[345]86
+CFLAGS-inl-tester.c += -Wno-array-bounds
endif
ifeq ($(subdir),gmon)