This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH] s390: Fix build error with gcc6 in utf8_utf16-z9.c.
- From: Stefan Liebler <stli at linux dot vnet dot ibm dot com>
- To: libc-alpha at sourceware dot org
- Date: Wed, 22 Jul 2015 13:58:54 +0200
- Subject: [PATCH] s390: Fix build error with gcc6 in utf8_utf16-z9.c.
- Authentication-results: sourceware.org; auth=none
Hi,
i get the following build error on s390x building utf8_utf16-z9.c with
gcc 6:
In file included from ../include/sys/cdefs.h:3:0,
from ../include/features.h:365,
from ../dlfcn/dlfcn.h:22,
from ../include/dlfcn.h:2,
from ../sysdeps/s390/s390-64/utf8-utf16-z9.c:27:
../iconv/skeleton.c: In function 'gconv':
../sysdeps/s390/s390-64/utf8-utf16-z9.c:430:30: error: array subscript
is above array bounds [-Werror=array-bounds]
if (__glibc_unlikely (inptr + 2 > inend)) \
^
../misc/sys/cdefs.h:385:52: note: in definition of macro '__glibc_unlikely'
# define __glibc_unlikely(cond) __builtin_expect ((cond), 0)
^
../iconv/loop.c:435:7: note: in expansion of macro 'BODY'
BODY
^
While including loop.c to construct the SINGLE(LOOPFCT) method for
converting from UTF-16 to UTF-8, the bytebuf array with length
MAX_NEEDED_INPUT is used as inptr. MAX_NEEDED_INPUT defaults to
MIN_NEEDED_INPUT if not defined before including loop.c.
Thus bytebuf has a length of 2.
This patch defines MAX_NEEDED_INPUT to MAX_NEEDED_TO, which is 4.
Ok for 2.22 or later?
Bye
Stefan
---
2015-07-22 Stefan Liebler <stli@linux.vnet.ibm.com>
* sysdeps/s390/s390-64/utf8-utf16-z9.c
(MAX_NEEDED_INPUT): New define.
(MAX_NEEDED_OUTPUT): New define.
diff --git a/sysdeps/s390/s390-64/utf8-utf16-z9.c b/sysdeps/s390/s390-64/utf8-utf16-z9.c
index 1425cb1..6712c1c 100644
--- a/sysdeps/s390/s390-64/utf8-utf16-z9.c
+++ b/sysdeps/s390/s390-64/utf8-utf16-z9.c
@@ -183,6 +183,7 @@ gconv_end (struct __gconv_step *data)
#define MIN_NEEDED_INPUT MIN_NEEDED_FROM
#define MAX_NEEDED_INPUT MAX_NEEDED_FROM
#define MIN_NEEDED_OUTPUT MIN_NEEDED_TO
+#define MAX_NEEDED_OUTPUT MAX_NEEDED_TO
#define LOOPFCT FROM_LOOP
/* The software implementation is based on the code in gconv_simple.c. */
#define BODY \
@@ -340,6 +341,7 @@ gconv_end (struct __gconv_step *data)
/* Conversion from UTF-16 to UTF-8. */
#define MIN_NEEDED_INPUT MIN_NEEDED_TO
+#define MAX_NEEDED_INPUT MAX_NEEDED_TO
#define MIN_NEEDED_OUTPUT MIN_NEEDED_FROM
#define MAX_NEEDED_OUTPUT MAX_NEEDED_FROM
#define LOOPFCT TO_LOOP