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

            Bug ID: 86360
           Summary: "inline" (and neither static nor extern) function not
                    emitted.
           Product: gcc
           Version: 8.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dwmw2 at infradead dot org
  Target Milestone: ---

https://gcc.gnu.org/onlinedocs/gcc/Inline.html says:

> When an inline function is not static, then the compiler must assume
> that there may be calls from other source files; since a global symbol
> can be defined only once in any program, the function must not be defined
> in the other source files, so the calls therein cannot be integrated. 
> Therefore, a non-static inline function is always compiled on its own
> in the usual fashion. 

Either I misunderstand that, or it isn't true:

$ cat foo.c

inline int foo(int a)
{
        return a+1;
}

int main(int a)
{
        return foo(a);
}

$ gcc -O0 -o- -S foo.c
        .file   "foo.c"
        .text
        .globl  bar
        .type   bar, @function
bar:
.LFB1:
        .cfi_startproc
        pushq   %rbp
        .cfi_def_cfa_offset 16
        .cfi_offset 6, -16
        movq    %rsp, %rbp
        .cfi_def_cfa_register 6
        subq    $16, %rsp
        movl    %edi, -4(%rbp)
        movl    -4(%rbp), %eax
        movl    %eax, %edi
        call    foo
        leave
        .cfi_def_cfa 7, 8
        ret
        .cfi_endproc
.LFE1:
        .size   bar, .-bar
        .ident  "GCC: (GNU) 8.1.1 20180502 (Red Hat 8.1.1-1)"
        .section        .note.GNU-stack,"",@progbits


Note the 'foo' function doesn't get emitted.

cf. https://github.com/openwrt/packages/pull/6377#issuecomment-401084671
    http://lists.osmocom.org/pipermail/osmocom-sdr/2018-June/001791.html

Reply via email to