INTEGER: ignore invalid -Warray-bounds from GCC-10

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
This commit is contained in:
Oliver Smith 2023-03-21 13:46:03 +01:00 committed by osmith
parent d762965f77
commit adaa1c62e1
1 changed files with 14 additions and 0 deletions

View File

@ -1336,9 +1336,16 @@ asn_int642INTEGER(INTEGER_t *st, int64_t value) {
} }
break; break;
} }
#if __GNUC__ == 10
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warray-bounds"
#endif
/* Copy the integer body */ /* Copy the integer body */
for(pstart = p, bp = buf, pend1 += add; p != pend1; p += add) for(pstart = p, bp = buf, pend1 += add; p != pend1; p += add)
*bp++ = *p; *bp++ = *p;
#if __GNUC__ == 10
#pragma GCC diagnostic pop
#endif
if(st->buf) FREEMEM(st->buf); if(st->buf) FREEMEM(st->buf);
st->buf = buf; st->buf = buf;
@ -1391,9 +1398,16 @@ asn_long2INTEGER(INTEGER_t *st, long value) {
} }
break; break;
} }
#if __GNUC__ == 10
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warray-bounds"
#endif
/* Copy the integer body */ /* Copy the integer body */
for(pstart = p, bp = buf, pend1 += add; p != pend1; p += add) for(pstart = p, bp = buf, pend1 += add; p != pend1; p += add)
*bp++ = *p; *bp++ = *p;
#if __GNUC__ == 10
#pragma GCC diagnostic pop
#endif
if(st->buf) FREEMEM(st->buf); if(st->buf) FREEMEM(st->buf);
st->buf = buf; st->buf = buf;