rui314 / 8cc

A Small C Compiler

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Miscompilation bug

andrewchambers opened this issue · comments

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);
}

Hi
I am a beginner looking to learn compiler theory side by side while working on real projects . I am backend developer with no experience here yet . Can I pick this bug for a beginner or could you suggest some other issue . Thanks

The backend for 8cc is not too complicated, though @rui314 doesn't seem to be maintaining this project actively at the moment.