[Bug optimization/10392] [3.3/3.4 regression] [SH] optimizer generates faulty array indexing
marcus at mc dot pp dot se
gcc-bugzilla@gcc.gnu.org
Fri Sep 12 19:12:00 GMT 2003
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=10392
------- Additional Comments From marcus at mc dot pp dot se 2003-09-12 19:06 -------
Subject: Re: [3.3/3.4 regression] [SH] optimizer generates faulty array indexing
Here is the reproduction recipe reworked as a runnable testsuite test.
If the program exits with code 0, the compiler is ok. If it exits
with code 1 or segfaults, the compiler is not ok.
---8<--- test.c ---8<---
#include <stdio.h>
#include <string.h>
char res[128];
char *use(char *z)
{
strncat(res, z, 10);
return "X";
}
void func(char *a, char *b)
{
char buf[128];
unsigned char i;
char *item[] = {
"one",
"two",
};
strcpy(buf, "buf");
for(i=0; i<2; i++) {
char *x;
use(item[i]);
x = use(buf);
use(a);
use(b);
use(x);
}
}
int main()
{
strcpy(res, "<");
func("A", "B");
strcat(res, ">");
/* printf("res=\"%s\"\n", res); */
return strcmp(res, "<onebufABXtwobufABX>")? 1 : 0;
}
---8<---
More information about the Gcc-bugs
mailing list