https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67925

--- Comment #5 from Arkadiusz Drabczyk <arkadiusz at drabczyk dot org> ---
-Winline is mentioned in the next paragraph. The whole sentence I posted in the
first comment is:

"Some calls cannot be integrated for various reasons (in particular, calls that
precede the function's definition cannot be integrated, and neither can
recursive calls within the definition)."

I think it's completely wrong - recursive functions can also be inlined:

$ ./gcc --version
gcc (GCC) 6.0.0 20151004 (experimental)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ 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)
{
        factorial(12);
        exit(0);
}
$ ./gcc bug1.c -O2 -S
$ cat bug1.s
        .file   "bug1.c"
        .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
        xorl    %edi, %edi
        call    exit
        .cfi_endproc
.LFE22:
        .size   main, .-main
        .ident  "GCC: (GNU) 6.0.0 20151004 (experimental)"
        .section        .note.GNU-stack,"",@progbits

I attach a suggested patch.

Reply via email to