Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

One method to verify if GCC is optimizing tail-recursion is to compile the code with the optimization flag "-O2" using the command "gcc -O2 filename.c -o outputfile". After that, use the command "objdump -d outputfile" to see the assembly code. If the tail-recursion has been optimized, there should be a "jmp" instruction instead of a "call" instruction at the end of the recursive function. Another method is to use the flag "-S" instead of "-c" while compiling, which will generate the assembly code in a separate file. You can then look at the assembly code to see if the tail-recursion has been optimized.