Closed andrewbird closed 8 months ago
I think this is a gcc bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102919 We may also ask @jwt27 if maybe he knows whether the fix from the url above is included or not into the current bundle.
That patch is present in 12.2. But I don't think it's the same issue. I can also replicate it with native gcc 12.2 using -m32
.
Thanks, so if you already made a native test-case, then maybe you are the one to fill in the upstream report? :)
You can use the following:
$ cat test.c
#include <string.h>
extern char bat_arg[20][32][512];
extern int stack_level;
void perform_shift()
{
int i;
for (i = 0; i < 32 - 1; i++)
{
strcpy(bat_arg[stack_level][i], bat_arg[stack_level][i + 1]);
if (!bat_arg[stack_level][i + 1][0])
break;
}
}
$ gcc -Wrestrict -m32 -O3 -c test.c
test.c: In function ‘perform_shift’:
test.c:11:5: warning: ‘strcpy’ accessing 1 byte at offsets [0, 327680] and [0, 327680] overlaps 1 byte at offset [0, 327679] [-Wrestrict]
11 | strcpy(bat_arg[stack_level][i], bat_arg[stack_level][i + 1]);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Without -m32
the warning also triggers, but only at -O1
.
Resolved on our side. Whoever wants to track the upstream ticket, should subscribe to the aforementioned gcc bugzilla ticket.