#56·8cc

Miscompilation bug

Author: andrewchambersCreated Mar 24, 2015Updated Jan 28, 2016

Following code aborts with 8cc at runtime, works with gcc 4.9.2 and tcc 0.9.26.

void abort(void);
void exit(int status);

struct {
  unsigned x2 : 2;
  unsigned x3 : 3;
} a = {2, 3} , *b = &a;

int main() {
  b->x3 += b->x2;
  if (b->x3 != 5)
    abort();
  exit(0);
}