Mail Archives: pgcc/1999/05/27/19:35:34
The following little program triggers a bug in pgcc-1.1.3 when
compiled with -O2 -fcompare-elim:
-----
#define bit(x) bitjes[x];
long long bitjes[64];
long long mvs[64][8];
void SetUp()
{
int b,x,y,z,b2;
long long board;
for (b = 0; b < 64; b++) {
b2 = b << 1;
for ( y = 0; y < 64; y += 8) {
board = 0;
x = y + 8;
z = (y>>3) + 1;
while (x < 64) {
board |= bit(x);
if (b2 & (1<<z)) break;
x += 8;
z++;
}
x = y-8;
z = (y>>3)-1;
while (x >= 0) {
board |= bit(x);
if (b2 & (1<<z)) break;
x -= 8;
z--;
}
mvs[b][y>>3] = board;
}
}
}
main()
{
int i, j;
for (i = 0; i < 64; i++)
bitjes[i] = 1ULL << i;
SetUp();
for (i = 0; i < 64; i++)
for (j = 0; j < 8; j++)
printf("%2d %d %lld\n", i, j, mvs[i][j]);
}
-----
Running the program should give some output, but when compiled
with -O2 -fcompare-elim it crashes at the line
mvs[b][y>>3] = board;
with for b a value of -64. Indeed, looking at the assembly output,
it seems pgcc lets b run from -64 to 63.
I do not know if this also happens with egcs-1.1.2. Version 1.1.1
of pgcc does not have problems here.
Ronald
- Raw text -