From: Michael Matz Date: Thu, 17 Oct 2024 15:42:40 +0000 (+0200) Subject: Fix for -Wstringop-overflow false positive X-Git-Tag: gdb-16-branchpoint~648 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=22ae2e1f702883e6e27d3ad96ee81a6266fbc51c;p=thirdparty%2Fbinutils-gdb.git Fix for -Wstringop-overflow false positive the way the overflow check was written wasn't understood by some GCC versions and produced false positives for the memset call being called potentially with object sizes that are larger than half address-space. --- diff --git a/bfd/merge.c b/bfd/merge.c index c811bc57eae..abb0269227e 100644 --- a/bfd/merge.c +++ b/bfd/merge.c @@ -181,9 +181,9 @@ sec_merge_maybe_resize (struct sec_merge_hash *table, unsigned added) do { - newnb *= 2; - if (!(unsigned int)newnb) + if (newnb >> (8 * sizeof(mapofs_type) - 1)) return false; + newnb *= 2; } while (NEEDS_RESIZE (bfdtab->count + added, newnb));