fuhsnn / slimcc

C11 compiler with GNU extensions for x86-64 Linux, working towards C23
MIT License
39 stars 6 forks source link

x87 stack may overflow or be clobbered #73

Closed fuhsnn closed 6 months ago

fuhsnn commented 6 months ago
#include <stdio.h>

long double fn(void) {
  asm("fninit");
  return 2.0L;
}
long double fn2 (long double a) {
  return  a + (a + (a + (a + (a + (a + (a + (a + a)))))));
}
int main(void) {
  printf("%Lf\n", 3.0L + fn() + 5.0L); // expected 10.0
  printf("%Lf\n", 3.0L + fn2(7.0L) + 5.0L); // expected 71.0
}