The following is creates wrong code because of aliasing issue:

typedef __SIZE_TYPE__ size_t;
typedef struct {
  size_t car;
  size_t cdr;
} cons;

int g(void);

size_t f(size_t a)
{
  size_t x;
  size_t *d;
  size_t i;
  d = &x;
  while ( (i = g()) != 0)
  {
    if (i == 30)
      d = &((cons*)i)->car;    
  }
  *d = 1;
}

This is reported here:
http://gcc.gnu.org/ml/gcc/2005-08/msg00041.html
http://gcc.gnu.org/ml/gcc-help/2005-08/msg00020.html

I think this is caused by &a->b being defined as a deference which is wrong.

-- 
           Summary: [4.0 Regression] Wrong code
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Keywords: wrong-code, alias
          Severity: normal
          Priority: P2
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: pinskia at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23192

Reply via email to