The following is a very simplified pb that appeared in ruby. Any attempt to simplify the example makes the bug disappear. Minimal optimization for the bug to appear: -O2 -fomit-frame-pointer The bug is "x" being put in the stack for "f" as the second argument, not the first one ("f" is a tail-call) -------------------------------------------------------------------------------- void raise(long) __attribute__ ((noreturn)); long f(double); long g(long i, double x) { if (x < 0) raise(1); return f(x); } -------------------------------------------------------------------------------- The test prints "0" when it should print "2" -------------------------------------------------------------------------------- void raise (long e) { exit(0); } long f(double i) { printf("%g\n", i); return 0; } long g(long i, double x); main() { g(0, 2.0); }
Will be fixed in gcc-2.96-64, fix was already commited into CVS head.