[Bug ipa/97945] New: undefined reference err when a function defined inline
dongjianqiang2 at huawei dot com
gcc-bugzilla@gcc.gnu.org
Mon Nov 23 11:00:16 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97945
Bug ID: 97945
Summary: undefined reference err when a function defined inline
Product: gcc
Version: 10.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: ipa
Assignee: unassigned at gcc dot gnu.org
Reporter: dongjianqiang2 at huawei dot com
CC: marxin at gcc dot gnu.org
Target Milestone: ---
$ cat z1.c
#define likely(x) __builtin_expect((x), 1)
#define unlikely(x) __builtin_expect((x), 0)
int a=10;
inline void test() {
__builtin_puts("hot");
a++;
__builtin_puts("hot");
}
void main() {
__builtin_puts("hot");
if (unlikely(a==2)) {
test();
}
__builtin_puts("hot");
}
gcc test.c -O2
in function `main':
test.c:(.text.startup+0x38): undefined reference to `test'
collect2: error: ld returned 1 exit status
But succeed when compiling with -fgnu89-inline.
More information about the Gcc-bugs
mailing list