[PATCH] handle vector and aggregate stores in -Wstringop-overflow [PR 97027]
Martin Sebor
msebor@gmail.com
Tue Jul 13 19:26:16 GMT 2021
An existing, previously xfailed test that I recently removed
the xfail from made me realize that -Wstringop-overflow doesn't
properly detect buffer overflow resulting from vectorized stores.
Because of a difference in the IL the test passes on x86_64 but
fails on targets like aarch64. Other examples can be constructed
that -Wstringop-overflow fails to diagnose even on x86_64. For
INSTANCE, the overflow in the following function isn't diagnosed
when the loop is vectorized:
void* f (void)
{
char *p = __builtin_malloc (8);
for (int i = 0; i != 16; ++i)
p[i] = 1 << i;
return p;
}
The attached change enhances the warning to detect those as well.
It found a few bugs in vectorizer tests that the patch corrects.
Tested on x86_64-linux and with an aarch64 cross.
Martin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gcc-97027.diff
Type: text/x-patch
Size: 32366 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20210713/227750d0/attachment-0001.bin>
More information about the Gcc-patches
mailing list