rui314 / 8cc

A Small C Compiler
MIT License
6.11k stars 744 forks source link

Miscompilation bug #56

Open andrewchambers opened 9 years ago

andrewchambers commented 9 years ago

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);
}
sandeep06011991 commented 8 years ago

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

andrewchambers commented 8 years ago

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