https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67925
--- Comment #6 from Arkadiusz Drabczyk <arkadiusz at drabczyk dot org> ---
Sorry, this code is wrong of course, value returned by factorial() must be used
to generate an actual code:
$ cat bug1.c
#include <stdio.h>
#include <stdlib.h>
inline static int factorial(unsigned int i)
{
if(i <= 1)
{
return 1;
}
return i * factorial(i - 1);
}
int main(void)
{
printf("%d\n", factorial(12));
exit(0);
}
$ cat bug1.s
.file "bug1.c"
.section .rodata.str1.1,"aMS",@progbits,1
.LC0:
.string "%d\n"
.section .text.startup,"ax",@progbits
.p2align 4,,15
.globl main
.type main, @function
main:
.LFB22:
.cfi_startproc
subq $8, %rsp
.cfi_def_cfa_offset 16
movl $1, %esi
movl $12, %eax
.p2align 4,,10
.p2align 3
.L2:
imull %eax, %esi
subl $1, %eax
cmpl $1, %eax
jne .L2
movl $.LC0, %edi
xorl %eax, %eax
call printf
xorl %edi, %edi
call exit
.cfi_endproc
.LFE22:
.size main, .-main
.ident "GCC: (GNU) 6.0.0 20151004 (experimental)"
.section .note.GNU-stack,"",@progbits