rui314 / 8cc

A Small C Compiler
MIT License
6.13k stars 740 forks source link

Miscompilation bug #58

Open andrewchambers opened 9 years ago

andrewchambers commented 9 years ago

Compiles and executes with gcc and tcc, aborts at runtime on 8cc.

if you remove the function call, then there is no error, probably error in float argument handling.

void abort(void);

double a = 1.0;

double f(double p1, double p2) {
  return p1 + p2;
}

int main() {
  if (f(a, a) != 2.0)
    abort();
  return 0;
}
andrewchambers commented 9 years ago

I should note #55 #56 #57 and #58 are all generated from the gcc torture suite. After automated test case reduction. I have no idea what this means in terms of being GPL derived code, or if we need to rewrite such small test cases.

There were around 80 miscompilations in the gcc torture suite. I have taken a few I hand selected because they look more or less straightforward. I don't want to flood the issue tracker. I can re review the test suite after the existing bugs are resolved.

I am only creating issues for miscompilation for now, because these are so much harder to locate, and can cause problems in real applications.