From adaa1c62e13a9ee8e7b978e6e9f67624f1ea7307 Mon Sep 17 00:00:00 2001 From: Oliver Smith Date: Tue, 21 Mar 2023 13:46:03 +0100 Subject: [PATCH] INTEGER: ignore invalid -Warray-bounds from GCC-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GCC 10.2.1 20210110 from Debian 11 generates an invalid Warray-bounds error. It was fixed in future GCC versions, I verified it with GCC 11.3.0. Ignore the warning, so we can build on Debian 11 with -Werror. Fix for: INTEGER.c: In function ‘asn_int642INTEGER’: INTEGER.c:1340:34: error: array subscript 0 is outside array bounds of ‘int64_t[1]’ {aka ‘long int[1]’} [-Werror=array-bounds] 1340 | for(pstart = p, bp = buf, pend1 += add; p != pend1; p += add) | ~~~~~~^~~~~~ INTEGER.c:1296:42: note: while referencing ‘value’ 1296 | asn_int642INTEGER(INTEGER_t *st, int64_t value) { | ~~~~~~~~^~~~~ Related: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93582 Change-Id: Ic10407e6d484ae29dc39edbdc6fcd0145e17e773 --- src/INTEGER.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/INTEGER.c b/src/INTEGER.c index 042fd75..0da24ad 100644 --- a/src/INTEGER.c +++ b/src/INTEGER.c @@ -1336,9 +1336,16 @@ asn_int642INTEGER(INTEGER_t *st, int64_t value) { } break; } +#if __GNUC__ == 10 +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Warray-bounds" +#endif /* Copy the integer body */ for(pstart = p, bp = buf, pend1 += add; p != pend1; p += add) *bp++ = *p; +#if __GNUC__ == 10 +#pragma GCC diagnostic pop +#endif if(st->buf) FREEMEM(st->buf); st->buf = buf; @@ -1391,9 +1398,16 @@ asn_long2INTEGER(INTEGER_t *st, long value) { } break; } +#if __GNUC__ == 10 +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Warray-bounds" +#endif /* Copy the integer body */ for(pstart = p, bp = buf, pend1 += add; p != pend1; p += add) *bp++ = *p; +#if __GNUC__ == 10 +#pragma GCC diagnostic pop +#endif if(st->buf) FREEMEM(st->buf); st->buf = buf;