This program: extern void func(void); extern __inline __attribute__((__always_inline__)) __attribute__((__gnu_inline__)) void func(void) { } extern void alias_target_func(void) {} extern void func(void) __attribute__((alias("alias_target_func"))); extern void caller(void) { func(); } fails to compile on 4.7, 4.8, and trunk with -c -fPIC -O2, saying: inline_alias.c: In function ‘caller’: inline_alias.c:5:13: error: inlining failed in call to always_inline ‘func’: function body can be overwritten at link time extern void func(void) __attribute__((alias("alias_target_func"))); ^ inline_alias.c:9:7: error: called from here func(); ^ It compiles on an old copy of gcc 4.5 I have lying around, although I don't think I agree with the generated code. gcc 4.5.1 (and gcc 4.8.2 with -O0) emit the call to func. With the alias removed, the call to func is not emitted, even at -O0. Oddly, without -fPIC, gcc 4.8 and trunk inline the call to func. trunk's behavior with -O0 (w/o -fPIC) is even stranger: it emits a call to alias_target_func. I can't reproduce that with other flags or on gcc 4.8. I think that the correct behavior would be to either (a) reject the alias as a redefinition of func or (b) accept this code as valid and inline func. Given the documented behavior for "extern __attribute__((gnu_inline))", the inline version of func should be used (or this code should be rejected outright). This may be related to PR33763 or PR46596, but I don't think it's the same issue as either one, although the respective fixes could be involved in the behavior changes. It came up in practice when openonload-201310 failed to build with _FORTIFY_SOURCE=2.
And with extern void func(void); extern void func(void) __attribute__((alias("alias_target_func"))); extern __inline __attribute__((__always_inline__)) __attribute__((__gnu_inline__)) void func(void) { } extern void alias_target_func(void) {} extern void caller(void) { func(); } you get t.c:4:89: error: redefinition of 'func' extern __inline __attribute__((__always_inline__)) __attribute__((__gnu_inline__)) void func(void) { } ^ t.c:2:13: note: previous definition of 'func' was here extern void func(void) __attribute__((alias("alias_target_func"))); ^ even though I'd say that providing an extern inline definition should still work? But yeah, gnu extern inlines have interesting behavior...
Dup.
. *** This bug has been marked as a duplicate of bug 46596 ***