public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug ipa/97945] New: undefined reference err when a function defined inline
@ 2020-11-23 11:00 dongjianqiang2 at huawei dot com
2020-11-23 11:18 ` [Bug c/97945] " jakub at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: dongjianqiang2 at huawei dot com @ 2020-11-23 11:00 UTC (permalink / raw)
To: gcc-bugs
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.
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c/97945] undefined reference err when a function defined inline
2020-11-23 11:00 [Bug ipa/97945] New: undefined reference err when a function defined inline dongjianqiang2 at huawei dot com
@ 2020-11-23 11:18 ` jakub at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-11-23 11:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97945
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |INVALID
Status|UNCONFIRMED |RESOLVED
Component|ipa |c
CC| |jakub at gcc dot gnu.org
--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
That is a user error.
The C99 and later standards mandate this behavior.
Either use static inline, or in one TU you need to use extern inline, or use
the GNU inline semantics.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-11-23 11:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-23 11:00 [Bug ipa/97945] New: undefined reference err when a function defined inline dongjianqiang2 at huawei dot com
2020-11-23 11:18 ` [Bug c/97945] " jakub at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).