Created attachment 49899 [details]
Test case to trigger the warning in -O3
This looks very similar to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87296 but occurs in GCC 10.0 to 10.2, not before.
The test case triggers the bug when compiled with `gcc -O3` but NOT with `gcc -O2 -ftree-vectorize` as in the above bug. Instead it is `gcc -O2 -fpeel-loops`
See reproducer on godbolt: https://godbolt.org/z/Ef1Pne
Interesting here is that it does not involve actual OOB access through VLA or size-0/size-1 hacks and is extremely sensitive. The following changes make the warning disappear:
- changing the array sizes (some combinations only)
- hiding the memcpy
- using C-Arrays
- using a single array
- removing either for-loop
Also the size of the 2nd array matters for the amount of warnings shown for that line.
It seems it is already fixed on trunk but all mentioned issues so far involved a VLA or OOB access so this is not a direct duplicate.
Of course the test code is a reduced MWE but you can guess the purpose.
Confirmed on the 10 branch. On trunk it was fixed in r11-1183.
*** This bug has been marked as a duplicate of bug 95353 ***
I did some work to reduce this further: https://godbolt.org/z/sezTPs
For some reason it seems to be related to std::array. So may I suggest to include the above (or the original reproducer) in the test cases to avoid regressions?