Subject: Re: Possible gcc bug?

From: Martin Costabel <[email-masked]>
Date: Sun, 11 Jun 2000 13:00:01 +0200

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.

--
Martin

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