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]

neat bug in alias analysis


This code:

typedef struct node {
  struct node *	left;
  struct node *	right;
} NODE;

void testRebalance (NODE ***ancestors,
		    int	count) {
  NODE **	nodepp;
  NODE *	nodep;
  NODE *	leftp;

  nodepp = ancestors[--count];
  nodep = *nodepp;
  leftp = nodep->left;

  nodep->left = leftp->right;
  leftp->right = nodep;

  *nodepp = (void*)42;
}

fails, the store or 42 into memory is moved before the two proceeding
lines, whereas this code:

typedef struct node {
  struct node *	left;
  struct node *	right;
} NODE;

void testRebalance (struct node ***ancestors,
		    int	count) {
  struct node **	nodepp;
  struct node *	nodep;
  struct node *	leftp;

  nodepp = ancestors[--count];
  nodep = *nodepp;
  leftp = nodep->left;

  nodep->left = leftp->right;
  leftp->right = nodep;

  *nodepp = (void*)42;
}

works.  The only difference is NODE v struct node, but they _are_ the
same type.  I did this is the top of the gcc tree just now.  If you
find a fix, let me know.


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