http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48194
Summary: gcc -std=c99 fails to link when calling inline function Product: gcc Version: 4.3.5 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassig...@gcc.gnu.org ReportedBy: a...@adamrosenfield.com $ cat test.c inline void foo() {} int main(void) { foo(); } $ gcc test.c -std=c99 test.c:(.text+0xa): undefined reference to `foo' collect2: ld returned 1 exit status Same result happens with -std=gnu99. Bug does NOT happen with optimization turned on: at any level besides -O0, this compiles correctly. $ gcc --version gcc-4.3 (Ubuntu 4.3.5-3ubuntu1) 4.3.5 Copyright (C) 2008 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. $ uname -a Linux epoch 2.6.35-27-generic #48-Ubuntu SMP Tue Feb 22 20:25:46 UTC 2011 x86_64 GNU/Linux This bug also happens on at least the following versions: gcc-4.4 (Ubuntu/Linaro 4.4.4-14ubuntu5) 4.4.5 gcc-4.5 (Ubuntu/Linaro 4.5.1-7ubuntu2) 4.5.1 gcc (GCC) 4.7.0 20110317 (experimental) It does NOT happen in: gcc-4.1 (GCC) 4.1.3 20080704 (prerelease) (Ubuntu 4.1.2-29ubuntu1) Related: bug 34697