This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: gcc optimisation bug



On Mon, 17 Jan 2000, Erik Sandberg wrote:

> I have found a GCC bug.

Same results under x86 gcc-20000114.  Here's an addition to the testsuite
for somebody to commit.  I don't have write access.


typedef struct card
{
  int col;
  int val;
  struct card *next;
} card;

card cards[13][4];

int main(void)
{
  int i, j;
  card *c = (card *)0;

  for (i = 0; i < 4; i++)
    for (j = 0; j < 13; j++)
      {
	cards[j][i].val = j;
	cards[j][i].col = i;
      }

  // link the cards together, so we get one big sorted deck of cards
  for (i = 0; i < 4; i++)
    for (j = 0; j < 13; j++)
      {
	cards[j][i].next = c;
	c = &cards[j][i];
      }

  // c should now point to element [12][3], which should be followed by all
  // other elements.

  // Now cycle through them
  for (i = 0; c; c = c->next)
    i += c->col*13 + c->val;

  if (i != 51*52/2)
    abort();

  exit(0);
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]