Please delete this thread, I have found the solution. Sorry for the inconvenience
Please delete this thread, I have found the solution. Sorry for the inconvenience
Last edited by ajacobs365; 10-30-2011 at 08:07 AM.
It already looks like it is capable of tail recursion elimination.
Indeed, gcc seems to think so.
Closer inspection of the optimised code shows that a jump is used where there should be a call.Code:$ gcc -S bar.c $ grep helper bar.s .globl count_helper .type count_helper, @function count_helper: call count_helper .size count_helper, .-count_helper $ gcc -S -O2 bar.c $ grep helper bar.s .globl count_helper .type count_helper, @function count_helper: .size count_helper, .-count_helper
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.