public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/15700] New: Inlining problem leads to miscompilation of glibc
@ 2004-05-28 21:34 aj at gcc dot gnu dot org
  2004-05-28 21:34 ` [Bug middle-end/15700] " aj at gcc dot gnu dot org
                   ` (23 more replies)
  0 siblings, 24 replies; 25+ messages in thread
From: aj at gcc dot gnu dot org @ 2004-05-28 21:34 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2005-04-01 11:39 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-28 21:34 [Bug middle-end/15700] New: Inlining problem leads to miscompilation of glibc aj at gcc dot gnu dot org
2004-05-28 21:34 ` [Bug middle-end/15700] " aj at gcc dot gnu dot org
2004-05-28 22:22 ` [Bug middle-end/15700] [3.5 Regression] " pinskia at gcc dot gnu dot org
2004-05-29  1:06 ` [Bug middle-end/15700] [3.5 Regression] [unit-at-a-time] " pinskia at gcc dot gnu dot org
2004-05-30 19:52 ` belyshev at lubercy dot com
2004-05-30 20:28 ` hubicka at ucw dot cz
2004-06-18 16:03 ` belyshev at lubercy dot com
2004-06-18 16:06 ` pinskia at gcc dot gnu dot org
2004-07-02 20:45 ` pinskia at gcc dot gnu dot org
2004-07-02 20:55 ` pinskia at gcc dot gnu dot org
2004-07-09  5:38 ` aoliva at gcc dot gnu dot org
2004-07-09  6:43 ` pinskia at gcc dot gnu dot org
2004-07-18  6:56 ` pinskia at gcc dot gnu dot org
2004-11-24 20:33 ` [Bug middle-end/15700] [4.0 " pinskia at gcc dot gnu dot org
2004-11-24 21:32 ` hjl at lucon dot org
2004-11-24 21:38 ` pinskia at gcc dot gnu dot org
2005-02-23 18:52 ` pinskia at gcc dot gnu dot org
2005-03-04 23:29 ` aoliva at gcc dot gnu dot org
2005-03-14 17:09 ` rth at gcc dot gnu dot org
2005-03-16 17:15 ` cvs-commit at gcc dot gnu dot org
2005-03-16 20:37 ` cvs-commit at gcc dot gnu dot org
2005-03-16 20:39 ` rth at gcc dot gnu dot org
2005-03-16 21:51 ` rth at gcc dot gnu dot org
2005-03-31 13:03 ` cvs-commit at gcc dot gnu dot org
2005-04-01 11:39 ` cvs-commit at gcc dot gnu dot 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).