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]

gcc codegen bug


Hi

I ran into what seems to be a codegen problem in egcs-2.91.66 in my code
and I'm sending you a small code snippet with the same symptoms. The
resulting binary will crash, according to gdb on line 22.

The incorrect crashing code is generated only when building at -O2, at
-O0, -O1 the code does not crash.

gcc version:
GNU CPP version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release) (i386
Linux/ELF)

compile line:
gcc -g -O2 bug.c -o bug

Thanks

Pavel Cisler
/* gcc -g -02 bug.c -o bug */

typedef struct { int m; } S;

S *f(void)
{
  return 0;
}

int main(void)
{
  S *p;
  int i;
  
  for (;;) {
    p = f();
    
    if (p == 0 || p->m != i) {
      i = 0;
    }
    
    if (p == 0) {
      break; // <- this causes incorrect code to be generated
      // return; // <- this would work
    }
    
    i = p->m;
  }
}

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