This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/49653] New: Undefined reference to inlined function with -O0,-std=c99
- From: "gary at intrepid dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 5 Jul 2011 22:13:32 +0000
- Subject: [Bug c/49653] New: Undefined reference to inlined function with -O0,-std=c99
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49653
Summary: Undefined reference to inlined function with
-O0,-std=c99
Product: gcc
Version: 4.5.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: gary@intrepid.com
Given,
$ cat -n inline_trouble.c
1 inline long trouble(long a, long b)
2 {
3 return a + b;
4 }
5
6 long two = 2;
7
8 int main()
9 {
10 long result = trouble(two, two);
11 return (int)result;
12 }
$ gcc --version
gcc (GCC) 4.5.1 20100924 (Red Hat 4.5.1-4)
This test compiles and links cleanly at -O2,-std=c99:
$ gcc -std=c99 -O2 inline_trouble.c
At -O0 -std=c99, it fails to link.
$ gcc -std=c99 -O0 inline_trouble.c
/tmp/ccXya7LE.o: In function `main':
inline_trouble.c:(.text+0x1d): undefined reference to `trouble'
collect2: ld returned 1 exit status
Note that gnu90 doesn't have this issue.
$ gcc -std=gnu90 -O0 inline_trouble.c
(Although GCC 4.5.1 is used in the test above, it is likely that this problem
can be reproduced with GCC built from the trunk.)
- Follow-Ups:
- [Bug c/49653] Undefined reference to inlined function with -O0,-std=c99
- From: pinskia at gcc dot gnu.org
- [Bug c/49653] Undefined reference to inlined function with -O0,-std=c99
- From: schaub.johannes at googlemail dot com
- [Bug c/49653] Undefined reference to inlined function with -O0,-std=c99
- From: rguenth at gcc dot gnu.org
- [Bug c/49653] Undefined reference to inlined function with -O0,-std=c99
- From: gary at intrepid dot com
- [Bug c/49653] Undefined reference to inlined function with -O0,-std=c99
- From: gary at intrepid dot com
- [Bug c/49653] Undefined reference to inlined function with -O0,-std=c99
- From: redi at gcc dot gnu.org
- [Bug c/49653] Undefined reference to inlined function with -O0,-std=c99
- From: gary at intrepid dot com
- [Bug c/49653] Undefined reference to inlined function with -O0,-std=c99
- From: redi at gcc dot gnu.org
- [Bug c/49653] Undefined reference to inlined function with -O0,-std=c99
- From: gary at intrepid dot com
- [Bug c/49653] Undefined reference to inlined function with -O0,-std=c99
- From: redi at gcc dot gnu.org
- [Bug c/49653] Undefined reference to inlined function with -O0,-std=c99
- From: gary at intrepid dot com