This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug optimization/10392] [3.3/3.4 regression] [SH] optimizer generates faulty array indexing
- From: "marcus at mc dot pp dot se" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 12 Sep 2003 19:06:55 -0000
- Subject: [Bug optimization/10392] [3.3/3.4 regression] [SH] optimizer generates faulty array indexing
- References: <20030413145600.10392.marcus@mc.pp.se>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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<---