This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug optimization/14562] Incorrect loop code caused by pass_ch
- From: "fjahanian at apple dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 12 Mar 2004 22:22:12 -0000
- Subject: [Bug optimization/14562] Incorrect loop code caused by pass_ch
- References: <20040312212525.14562.fjahanian@apple.com>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From fjahanian at apple dot com 2004-03-12 22:22 -------
Here is an executable test case:
typedef struct TypHeader {
unsigned long size;
struct TypHeader * * ptr;
} * TypHandle;
void gorf (unsigned long h, unsigned long k, TypHandle hdRes, TypHandle hdTmp)
{
while ( hdTmp < ((hdRes)->ptr)[k-h] ) {
((hdRes)->ptr)[k] = ((hdRes)->ptr)[k-h];
k = k-h;
}
}
int main()
{
int i;
struct TypHeader* arrTypHeader[6];
TypHandle hdTmp;
struct TypHeader hd;
hd.ptr = arrTypHeader;
for (i=0; i < 6; i++)
{
arrTypHeader[i] = (struct TypHeader*)malloc(sizeof(struct TypHeader));
arrTypHeader[i]->size = i;
}
gorf(1, 5, &hd, arrTypHeader[0]);
for (i=0; i < 6; i++)
{
printf(" size = %d\n", arrTypHeader[i]->size);
}
return 0;
}
Compiled with -O0 produces following results:
size = 0
size = 1
size = 1
size = 2
size = 3
size = 4
Compiled with -O1 produces incorrect results:
size = 0
size = 1
size = 2
size = 3
size = 4
size = 5
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14562