Possible gcc bug?

Martin Costabel costabel at wanadoo.fr
Sun Jun 11 21:00:01 EST 2000

Geoff Hutchison wrote:

> If I'm being a complete moron and doing something silly, please let
> me know and I'll eat my words.

I think you do: You are passing over the array bounds. If I remember my
C basics (which I never really learned either) correctly,

double field[loopX][loopY];

allows indices running from 0 to loopX-1 and from 0 to loopY-1.

In your first loop

  /* Initialize arrays */
  for (x = 0; x <= loopX; x++)
    for (y = 0; y <= loopY; y++)
      	field[x][y] = 0.0;
	points[maxX * x + y].ptX = x;
	points[maxX * x + y].ptY = y;

you are clobbering random memory locations that may be different for
different compiler optimisation levels.

Replace "<=" by "<", and your errors will go away.


** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

More information about the Linuxppc-dev mailing list