This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/15700] New: Inlining problem leads to miscompilation of glibc
- From: "aj at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 28 May 2004 07:15:08 -0000
- Subject: [Bug middle-end/15700] New: Inlining problem leads to miscompilation of glibc
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
glibc cannot be compiled by current 3.5 mainline on AMD64 (but same
situation on ia64). I've reduced the error to the following example:
extern int __internal_getnetgrent_r (void);
static int
internal_getnetgrent_r (void)
{
return 1;
}
extern __typeof (internal_getnetgrent_r) __internal_getnetgrent_r __attribute__
((alias ("internal_getnetgrent_r")));
int
test (void)
{
return internal_getnetgrent_r ();
}
With GCC 3.5 of today I get internal_getnetgrent_r undefined:
reger:/tmp:[0]$ /opt/gcc/3.5-devel/bin/gcc -O2 -c test.c
reger:/tmp:[0]$ nm test.o
U internal_getnetgrent_r
0000000000000000 T test
reger:/tmp:[0]$ /opt/gcc/3.5-devel/bin/gcc -O2 -c test.c
reger:/tmp:[0]$ nm test.o
U internal_getnetgrent_r
0000000000000000 T test
But older GCC versions (3.3 and 3.4.0) produce:
reger:/tmp:[0]$ gcc -O2 -c test.c
reger:/tmp:[0]$ nm test.o
0000000000000000 T __internal_getnetgrent_r
0000000000000000 t internal_getnetgrent_r
0000000000000010 T test
reger:/tmp:[0]$ /opt/gcc/3.4-devel/bin/gcc -O2 -c test.c
reger:/tmp:[0]$ nm test.o
0000000000000000 T __internal_getnetgrent_r
0000000000000000 t internal_getnetgrent_r
0000000000000010 T test
Is this a bug in glibc or in GCC?
3.5 inlines the code but 3.4 not, the difference in the assembler is:
--- test-3.5.s 2004-05-27 17:40:11.255202552 +0200
+++ test-3.4.s 2004-05-27 17:39:51.789864313 +0200
@@ -2,14 +2,20 @@
.globl __internal_getnetgrent_r
.set __internal_getnetgrent_r,internal_getnetgrent_r
.text
- .align 4
+ .p2align 4,,15
+ .type internal_getnetgrent_r, @function
+internal_getnetgrent_r:
+.LFB2:
+ movl $1, %eax
+ ret
+.LFE2:
+ .size internal_getnetgrent_r, .-internal_getnetgrent_r
.p2align 4,,15
.globl test
.type test, @function
test:
.LFB3:
- movl $1, %eax
- ret
+ jmp internal_getnetgrent_r
.LFE3:
.size test, .-test
.section .eh_frame,"a",@progbits
It seems the following statement:
.set __internal_getnetgrent_r,internal_getnetgrent_r
should not be emitted if the function is inlined.
--
Summary: Inlining problem leads to miscompilation of glibc
Product: gcc
Version: 3.5.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: middle-end
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: aj at gcc dot gnu dot org
CC: gcc-bugs at gcc dot gnu dot org,hubicka at gcc dot gnu
dot org
GCC build triplet: x86_64-linux-gnu
GCC host triplet: x86_64-linux-gnu
GCC target triplet: x86_64-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15700